Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Invalid use of Me keyword 1

Status
Not open for further replies.

vttech

Technical User
Jan 28, 2006
297
US
I am getting a compile error:

Invalid use of Me keyword


Code:
Private Sub InputLogInOut()

Dim strSQl As String
Dim cQuote As String

cQuote = """"

strSQl = "INSERT INTO tblLogInOut (Day,WorkDate,LogIn,LogOut,Site,Activity) values " _
& "(" & cQuote & Me!txtDay.Value & cQuote & "," & "#" & Me!cboWorkDate.Value & "#" _
& "," & "#" & Me!txtLogin.Value & "#" & "," & "#" & Me!txtLogOut.Value & _
"#" & "," & cQuote & Me!cboSite.Value & cQuote & "," & cQuote & _
Me!cboActivity.Value & cQuote & ")"

Debug.Print strSQl

CurrentProject.Connection.Execute strSQl

End Sub
[code]

Debug brings me to  [b]Me!txtDay.Value[/b]


what am I missing??


Newbie in search of knowledge
 
Is InputLogInOut a procedure in the form's class module ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
InputLogInOut is a procedure in the forms class module
It seems to run but then I get

syntax error in Insert Into Statement

Debug brings me to

Code:
CurrentProject.Connection.Execute strSQl

immediate window produces

INSERT INTO tblLogInOut (Day,WorkDate,LogIn,LogOut,Site,Activity) values ("Sunday",#6/18/2006#,#04:00 AM#,#04:15 AM#,"Safe Harbor","Holiday")

which looks good, but I know I am missing something. So I tried to run the code in a module to isolate the code and it gave me the before mention error


Newbie in search of knowledge
 
For me, a better syntax:
INSERT INTO tblLogInOut ([!][[/!]Day[!]][/!],WorkDate,LogIn,LogOut,Site,Activity) values ([!]'[/!]Sunday[!]'[/!],#6/18/2006#,#04:00 AM#,#04:15 AM#,[!]'[/!]Safe Harbor[!]'[/!],[!]'[/!]Holiday[!]'[/!])


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
why the brackets around Day?

Funny thing once I placed DoCmd.RunSQL strSQl instead of
CurrentProject.Connection.Execute strSQl I got No error message

Why is CurrentProject.Connection.Execute strSQl not working for me?

Newbie in search of knowledge
 
Have you tried my suggested strSQL (brackets and single quotes) ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Yes I tried your suggested and it worked once I used the brackets as well but I don't understand Why I needed the brackets around Day. Is Day a Keyword?? and what is the difference between a double quotes and single quotes??



Newbie in search of knowledge
 
Sure Day is a reserved word !
It's a date function.

CurrentProject.Connection is an ADODB object and I'm not sure ADO handles double quotes very well.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top