Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / New Users / April 2005

Tip: Looking for answers? Try searching our database.

run time error 2447

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lindsey M - 11 Apr 2005 16:32 GMT
Hi everyone, hope you are well :)

I have the following code for my command button, but when I click the "OK"
button, an error comes up with the following

Run time error 2447

Here is my code:

Private Sub cmdOK_Click()

Dim strSQL As String
Dim sUserID As String
Dim sRoomID As String
Dim dDate As Date
Dim StartTime As String
Dim EndTime As String

strSQL = "Select * from tblSchedule"
sUserID = Me.txtUser
sRoomID = Me.cmbRoomReq
StartTime = Me.lstStart
EndTime = Me.lstEnd

   Me.lstConflict.Requery

       If Me.lstConflict.ListCount > 0 Then
           MsgBox "Sorry, no can do!"
       Else

           DoCmd.RunSQL "INSERT INTO tblSchedule " & _
               "(UserID, RoomID, Date, StartTime, EndTime) " & _
               "VALUES (" & sUserID & ", " & sRoomID & ", #" & _
               dDate & "#, #" & StartTime & "#, #" & EndTime & "#)"

       End If

End Sub

Can anyone tell me where I might be going wrong here?

Cheers
Lindsey

p.s., when i click on the Help button on the error box that appears, it
doesn't seem to be working so i can't figure out where the problem lays
David Seeto - 12 Apr 2005 04:49 GMT
Hi Lindsey,

I think error 2447 refers to invalid syntax in your INSERT query - looking
at it, it's probably having problems with "Date": this is sort of a
reserved word in Access but not quite, so although you've been able to
create a table with this column name, SQL is interpreting it differently.
I'd recommend changing it to "EntryDate" or something.

Even if you don't want to do this, you can probably fix the problem by
placing [ and ] around the field names, like so:
DoCmd.RunSQL "INSERT INTO tblSchedule " & _
            "([UserID], [RoomID], [Date], [StartTime], [EndTime]) " & _
            "VALUES (" & sUserID & ", " & sRoomID & ", #" & _
            dDate & "#, #" & StartTime & "#, #" & EndTime & "#)"
Ofer - 12 Apr 2005 07:32 GMT
Hi Lindsey

You declared sUserID and sRoomID As String
but in you query you treat it as Number
If the field in the table is number then declare it as
Number, if not then you should write the query as follow:

DoCmd.RunSQL "INSERT INTO tblSchedule " & _
"(UserID, RoomID, Date, StartTime, EndTime) " & _
"VALUES ('" & sUserID & "', '" & sRoomID & "', #" & _
dDate & "#, #" & StartTime & "#, #" & EndTime & "#)"

>-----Original Message-----
>Hi everyone, hope you are well :)
[quoted text clipped - 45 lines]
>
>.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.