Wrox Programmer Forums
|
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 Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 14th, 2007, 04:42 AM
Authorized User
 
Join Date: Jun 2007
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ivanlaw Send a message via Yahoo to ivanlaw
Default 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.

 
Old December 14th, 2007, 11:00 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

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
 
Old December 15th, 2007, 02:43 AM
Authorized User
 
Join Date: Jun 2007
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ivanlaw Send a message via Yahoo to ivanlaw
Default

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.

 
Old December 17th, 2007, 11:54 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

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
 
Old December 17th, 2007, 11:55 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

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
 
Old December 19th, 2007, 04:47 AM
Authorized User
 
Join Date: Jun 2007
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ivanlaw Send a message via Yahoo to ivanlaw
Default

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.

 
Old December 19th, 2007, 08:26 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

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
 
Old December 28th, 2007, 04:49 AM
Authorized User
 
Join Date: Jun 2007
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ivanlaw Send a message via Yahoo to ivanlaw
Default

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?

 
Old December 28th, 2007, 09:02 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Query Error & Run-Time Error 3022 DavidWE Access 1 July 31st, 2008 11:17 AM
error 3464 'data type mismatch in criteria express Vince_421 Access VBA 3 May 3rd, 2007 06:45 AM
run-time error(s) Chacko C++ Programming 0 March 4th, 2007 02:28 PM
Run Time Error JBond Access VBA 0 May 27th, 2004 09:50 AM
RUN-TIME ERROR compcad Beginning VB 6 2 May 21st, 2004 02:01 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.