 |
| 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
|
|
|
|

July 27th, 2007, 02:30 PM
|
|
Registered User
|
|
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
|
|
Insert Into Query.
Hi please check below query.
"INSERT INTO Utilization (OnDate,UserID,Completed,StartTime,EndTime,Priorit yID_FKey,EventID_FKey) VALUES (#07/27/2007#,'ranjaria','No','07/27/2007 12:21:23 PM',NULL,1,42)"
--------------
It gives error as "Data type mismatch in criteria expression"
I did figure it out as it has problem with "Now()" i have used in query. (which is in single quote see actua query as below:
"INSERT INTO Utilization (OnDate,UserID,Completed,StartTime,EndTime,Priorit yID_FKey,EventID_FKey)" & " VALUES (#" & txt_date.Value & "#,'" & GetLoggedInUserName() & "','No'" & ",'" & Now() & "'," & "NULL," & cmb_priority.Value & "," & cmb_events.Value & ")")
Rupen Anjaria.:)
------------------
It is not difficult to be on TOP...It is difficult when you carry Truth,Commitment and Transparency with you.
|
|

July 28th, 2007, 08:58 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Hi Rupen,
Just a couple of pointers. Things like this are hard to debug because its all clumped together..
Try breaking out the code above so each part is assigned to a variable, and then
generate the SQL based on these variables. This will allow you to step through
and see what each Item is actually ending up to be.. You will eventually hit
one that is the wrong type!
Good luck, please come back if you still have problems.
Rob
<center>"Nothing can stop the man with the right mental attitude from achieving his goal;
nothing on earth can help the man with the wrong mental attitude".
Thomas Jefferson</center>
|
|

July 29th, 2007, 04:01 AM
|
|
Registered User
|
|
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
|
|
Hi Rob,
I tried to debug the statement, also copied the entire statement from debug windoe to MS Access Query designer and executed over there, to my surprise it didn't give any error to me. It gives error at VBA level.
I suspect it has problem while storing Now() value.
Please help!!
Thanks,
Rupen Anjaria.:)
------------------
It is not difficult to be on TOP...It is difficult when you carry Truth,Commitment and Transparency with you.
|
|

July 29th, 2007, 04:35 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Rupen,
OK, would be very helpful for me if you could post your code and actually tell
me what the error is.. ;) :)
Regards,
Rob
<center>"Nothing can stop the man with the right mental attitude from achieving his goal;
nothing on earth can help the man with the wrong mental attitude".
Thomas Jefferson</center>
|
|

July 30th, 2007, 06:13 AM
|
|
Registered User
|
|
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
|
|
Hi Rob,
Thank your for help, but it was 'No', which was problemetic, In table design it was Yes/No field and hence can't give in ''.
That's all.
Thanks,
Rupen Anjaria.:)
------------------
It is not difficult to be on TOP...It is difficult when you carry Truth,Commitment and Transparency with you.
|
|

July 30th, 2007, 09:58 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
|
|
No Problem, glad we got there in the end!
<center>"Nothing can stop the man with the right mental attitude from achieving his goal;
nothing on earth can help the man with the wrong mental attitude".
Thomas Jefferson</center>
|
|
 |