Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Add a month to the date entered in a msflexgrid i get type mismatch

Posted on 2013-10-22
11
Medium Priority
?
469 Views
Last Modified: 2013-10-22
I get error: Type mismatch
How can i write this:
Dim LastMonth As Date

LastMonth = gridHouse.TextMatrix(gridHouse.Rows - 1, 1)

In the msflexgrid date is like this:May/2013
0
Comment
Question by:isnoend2001
  • 4
  • 3
  • 3
  • +1
11 Comments
 
LVL 46

Assisted Solution

by:aikimark
aikimark earned 1200 total points
ID: 39592662
Try this.  You need to cast the text as a date data type.
LastMonth = CDate(gridHouse.TextMatrix(gridHouse.Rows - 1, 1))

Open in new window

0
 

Author Comment

by:isnoend2001
ID: 39592734
Thanks : aikimark, but still the same error: error13 type mismatch
0
 
LVL 46

Assisted Solution

by:aikimark
aikimark earned 1200 total points
ID: 39592760
please verify the contents of that cell
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:isnoend2001
ID: 39592792
already did just to be sure
 MsgBox gridHouse.TextMatrix(gridHouse.Rows - 1, 1)
returns Aug\2014
0
 
LVL 76

Assisted Solution

by:GrahamSkan
GrahamSkan earned 400 total points
ID: 39592822
"Aug\2014" can't be converted to a date.

Try:
LastMonth = Replace(gridHouse.TextMatrix(gridHouse.Rows - 1, 1), "\","")

Open in new window

0
 
LVL 49

Assisted Solution

by:Martin Liss
Martin Liss earned 400 total points
ID: 39592825
Which is it
In the msflexgrid date is like this:May/2013

or

returns Aug\2014

Note the direction of the slashes.
0
 
LVL 76

Assisted Solution

by:GrahamSkan
GrahamSkan earned 400 total points
ID: 39592834
I see that a space got lost in my code (third Replace argument)

It should have been:
LastMonth = Replace(gridHouse.TextMatrix(gridHouse.Rows - 1, 1), "\"," ")
0
 
LVL 46

Accepted Solution

by:
aikimark earned 1200 total points
ID: 39592847
If it is a backslash, instead of the front slash you originally posted, you can do something similar to what GrahamSkan suggested and change the backslash character.
LastMonth = CDate(Replace(gridHouse.TextMatrix(gridHouse.Rows - 1, 1), "\","/"))

Open in new window

0
 

Author Comment

by:isnoend2001
ID: 39592852
backslash (\)
LastMonth = Replace(gridHouse.TextMatrix(gridHouse.Rows - 1, 1), "\", "") returns the same error
see grid attached
mismatch-error.jpg
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 39592862
Sorry. My first comment had a typo in the code. The second version should work.
0
 

Author Closing Comment

by:isnoend2001
ID: 39592872
Thanks that fixes it
LastMonth = CDate(Replace(gridHouse.TextMatrix(gridHouse.Rows - 1, 1), "\","/"))
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question