|
|
 |
| Access VBA Discuss using VBA for Access programming. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Access VBA section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

December 14th, 2007, 04:42 AM
|
|
Authorized User
|
|
Join Date: Jun 2007
Location: , , .
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Run-time error '3464':
The error is data type mismatch in criteria expression.
My is below:
DoCmd.OpenReport "rptMember", acViewPreview, , "ExpiryDate = " & txtDate.Value
My table got set an input mask for to become 99/99(month and year).Then the data type is text.Is it got anything wrong with my setting or coding?
Please help me...Thank you.
|

December 14th, 2007, 11:00 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,114
Thanks: 2
Thanked 4 Times in 4 Posts
|
|
Try
DoCmd.OpenReport "rptMember", acViewPreview, , "[ExpiryDate] = #" & Me.txtDate & "#"
You forgot the delimiters around the date.
Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
|

December 15th, 2007, 02:43 AM
|
|
Authorized User
|
|
Join Date: Jun 2007
Location: , , .
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi there,
I have try your coding that you post to me,my program can run.But it still can not detect the data out from the database.May I know reason?From the table I can see the data is 06/03, so i type 06/03 in the text box(txtDate),but the report does not any related data from the table.
Thank you.
|

December 17th, 2007, 11:54 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,060
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
I would modify this slightly to do this instead:
Dim dtDate As Date
Dim sLink As String
Dim sDoc As String
sDoc = "rptMember"
dtDate = Me.txtDate
sLink = "[ExpiryDate] = #" & dtDate & "#"
DoCmd.OpenReport sDoc, acViewPreview, , sLink
That being said, it doesn't look like your input is a date. So this won't work becuase it is execting a date data type.
What you will need to do is:
Dim sDate As String
Dim sLink As String
Dim sDoc As String
sDoc = "rptMember"
dtDate = Me.txtDate
sLink = "[ExpiryDate] = '" & dtDate & "'"
DoCmd.OpenReport sDoc, acViewPreview, , sLink
Did that help?
mmcdonal
Look it up at: http://wrox.books24x7.com
|

December 17th, 2007, 11:55 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,060
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
Sorry, didn't preview the post.
What you will need to do is:
Dim sDate As String
Dim sLink As String
Dim sDoc As String
sDoc = "rptMember"
dtDate = Me.txtDate
sLink = "[ExpiryDate] = '" & sDate & "'"
DoCmd.OpenReport sDoc, acViewPreview, , sLink
mmcdonal
Look it up at: http://wrox.books24x7.com
|

December 19th, 2007, 04:47 AM
|
|
Authorized User
|
|
Join Date: Jun 2007
Location: , , .
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi there,
I already try all you post to me, but it also can not show out the data from the table.Why?Should I provide you any information so that you can solve it for me?
Thank you.
|

December 19th, 2007, 08:26 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,060
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
If you can post the table information like field name and data type, and then the formatting of the text box, and then the pertinent query information from the report, we should be able to help.
The issue is that between the table data type, the variable and its data type, and the query and parameters it can take, the data type is not matching up somewhere. This is the most common cause of software issues: variable collisions.
mmcdonal
Look it up at: http://wrox.books24x7.com
|

December 28th, 2007, 04:49 AM
|
|
Authorized User
|
|
Join Date: Jun 2007
Location: , , .
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
From the table first,field name is ExpiryDate.Then its data type is a text and it got an input mask setting for an example, "06/03".
Then i just use the coding i already post to try and get somethings from the table named "Member".
I already try a lots of methods those i have learn and found out from the web site, but still can not.Now i really dun where is my mistake was.
Is that enough information for you to help me?
|

December 28th, 2007, 09:02 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,060
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
I would have to see the database and what you are doing. The code posted should work. Let me refresh:
The table name is "Member."
In that table you have a column called "ExpiryDate."
ExpiryDate is data type Text (number of characters? 50?)
ExpiryDate has an input mask of 99/99.
Please note, the input mask is requiring Numbers, not text.
How is the value stored when you enter it? For example, if the user enters 01/01, is it stored as 01/01, or as 1/1?
That being said, the code posted should work, but for a leading zeros issue.
Can you send the database with just the form and table and query?
mmcdonal
Look it up at: http://wrox.books24x7.com
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |