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 July 27th, 2007, 02:30 PM
Registered User
 
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rupen
Default 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.
 
Old July 28th, 2007, 08:58 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

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>
 
Old July 29th, 2007, 04:01 AM
Registered User
 
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rupen
Default

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.
 
Old July 29th, 2007, 04:35 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

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>
 
Old July 30th, 2007, 06:13 AM
Registered User
 
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rupen
Default

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.
 
Old July 30th, 2007, 09:58 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

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>





Similar Threads
Thread Thread Starter Forum Replies Last Post
Where does insert query go? bph Access VBA 5 June 12th, 2007 12:26 PM
New Insert Query Neal SQL Server 2000 3 May 8th, 2007 01:22 PM
INSERT Query Neal SQL Server 2000 2 May 3rd, 2007 05:18 PM
I solved insert query.now see this Update Query. [email protected] VB.NET 2002/2003 Basics 2 September 21st, 2006 12:48 AM
INSERT INTO QUERY sanjna000 Excel VBA 5 November 26th, 2004 12:41 AM





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