If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#21
|
|||
|
|||
RunTime Error 3134
Hi,
I inserted a message box, and it worked. However, the code still didn't do anything. "Douglas J. Steele" wrote: Is the code executing? If you look at the On Click property of the form, does it say [Event Procedure]? If not, correct that. If it does, try putting a breakpoint in your code to see whether it runs (or a message box) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "ajhome" wrote in message ... Hello Douglas, Thank you for your help. I have entered the code just as you have said. However, it still doesn't work. I am not getting an error message, it just doesn't do anything. It acts as if the button doesn't have any coding behind it. "Douglas J. Steele" wrote: If they're text fields, you need quotes around them, just as you have for the CurrentUser field. CurrentDb.Execute "INSERT INTO tblMovement " & _ "(EmpID, InsertDate, EffectiveDate, CurrentUser, " & _ "NewSupervisor, NewTitle, NewCenter) " & _ "VALUES (" & lstSelectEmp.Column(0) & ", " & _ Format(txtInsertDate, "\#yyyy\-mm\-dd\#") & _ "," & Format(txtEffectiveDate, "\#yyyy\-mm\-dd\#") & ", " & _ Chr$(34) & txtCurrent & Chr$(34) & ", " & _ Chr$(34) & cboNewSupervisor & Chr$(34) & ", " & _ Chr$(34) & cboNewTitle & Chr$(34) & ", " & _ Chr$(34) & cboNewCenter & Chr$(34) & ")" -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "ajhome" wrote in message ... Hello, Would someone please tell me what is wrong with this code: CurrentDb.Execute "INSERT INTO tblMovement (EmpID, InsertDate, EffectiveDate, CurrentUser, NewSupervisor, NewTitle, NewCenter) " & _ "VALUES (" & lstSelectEmp.Column(0) & ", " & Format(txtInsertDate, "\#yyyy\-mm\-dd\#") & _ "," & Format(txtEffectiveDate, "\#yyyy\-mm\-dd\#") & ", " & Chr$(34) & txtCurrent & Chr$(34) & ", " & cboNewSupervisor & _ ", " & cboNewTitle & ", " & cboNewCenter & ")" The last 3 fields are text fields. When I put quotes around them, it gives me an error message of too few fields. Thanks, AJ |
#22
|
|||
|
|||
RunTime Error 3134
Try changing to:
Dim strSQL As String strSQL = "INSERT INTO tblMovement " & _ "(EmpID, InsertDate, EffectiveDate, CurrentUser, " & _ "NewSupervisor, NewTitle, NewCenter) " & _ "VALUES (" & lstSelectEmp.Column(0) & ", " & _ Format(txtInsertDate, "\#yyyy\-mm\-dd\#") & _ "," & Format(txtEffectiveDate, "\#yyyy\-mm\-dd\#") & ", " & _ Chr$(34) & txtCurrent & Chr$(34) & ", " & _ Chr$(34) & cboNewSupervisor & Chr$(34) & ", " & _ Chr$(34) & cboNewTitle & Chr$(34) & ", " & _ Chr$(34) & cboNewCenter & Chr$(34) & ")" Debug.Print strSQL CurrentDb.Execute strSQL, dbFailOnError When the code runs, go to the Immediate Window (Ctrl-G) and look at the SQL string that was written there. Does it look correct? What happens if you create a query, paste that same SQL into it and run it? Does adding the dbFailOnError parameter cause any meaning error to be raised? -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "ajhome" wrote in message ... Hi, I inserted a message box, and it worked. However, the code still didn't do anything. "Douglas J. Steele" wrote: Is the code executing? If you look at the On Click property of the form, does it say [Event Procedure]? If not, correct that. If it does, try putting a breakpoint in your code to see whether it runs (or a message box) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "ajhome" wrote in message ... Hello Douglas, Thank you for your help. I have entered the code just as you have said. However, it still doesn't work. I am not getting an error message, it just doesn't do anything. It acts as if the button doesn't have any coding behind it. "Douglas J. Steele" wrote: If they're text fields, you need quotes around them, just as you have for the CurrentUser field. CurrentDb.Execute "INSERT INTO tblMovement " & _ "(EmpID, InsertDate, EffectiveDate, CurrentUser, " & _ "NewSupervisor, NewTitle, NewCenter) " & _ "VALUES (" & lstSelectEmp.Column(0) & ", " & _ Format(txtInsertDate, "\#yyyy\-mm\-dd\#") & _ "," & Format(txtEffectiveDate, "\#yyyy\-mm\-dd\#") & ", " & _ Chr$(34) & txtCurrent & Chr$(34) & ", " & _ Chr$(34) & cboNewSupervisor & Chr$(34) & ", " & _ Chr$(34) & cboNewTitle & Chr$(34) & ", " & _ Chr$(34) & cboNewCenter & Chr$(34) & ")" -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "ajhome" wrote in message ... Hello, Would someone please tell me what is wrong with this code: CurrentDb.Execute "INSERT INTO tblMovement (EmpID, InsertDate, EffectiveDate, CurrentUser, NewSupervisor, NewTitle, NewCenter) " & _ "VALUES (" & lstSelectEmp.Column(0) & ", " & Format(txtInsertDate, "\#yyyy\-mm\-dd\#") & _ "," & Format(txtEffectiveDate, "\#yyyy\-mm\-dd\#") & ", " & Chr$(34) & txtCurrent & Chr$(34) & ", " & cboNewSupervisor & _ ", " & cboNewTitle & ", " & cboNewCenter & ")" The last 3 fields are text fields. When I put quotes around them, it gives me an error message of too few fields. Thanks, AJ |
#23
|
|||
|
|||
RunTime Error 3134
Good Morning,
It tells me the following message: "The INSERT INTO statement contains the following unknown field name: 'NewSupervisor'. When I take that field out, I get the same error message for the other fields as well. I have doubled checked my form and table to make sure that I have spelled everything correctly and the same, and I have. What else could be causing that error? "Douglas J. Steele" wrote: Try changing to: Dim strSQL As String strSQL = "INSERT INTO tblMovement " & _ "(EmpID, InsertDate, EffectiveDate, CurrentUser, " & _ "NewSupervisor, NewTitle, NewCenter) " & _ "VALUES (" & lstSelectEmp.Column(0) & ", " & _ Format(txtInsertDate, "\#yyyy\-mm\-dd\#") & _ "," & Format(txtEffectiveDate, "\#yyyy\-mm\-dd\#") & ", " & _ Chr$(34) & txtCurrent & Chr$(34) & ", " & _ Chr$(34) & cboNewSupervisor & Chr$(34) & ", " & _ Chr$(34) & cboNewTitle & Chr$(34) & ", " & _ Chr$(34) & cboNewCenter & Chr$(34) & ")" Debug.Print strSQL CurrentDb.Execute strSQL, dbFailOnError When the code runs, go to the Immediate Window (Ctrl-G) and look at the SQL string that was written there. Does it look correct? What happens if you create a query, paste that same SQL into it and run it? Does adding the dbFailOnError parameter cause any meaning error to be raised? -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) |
#24
|
|||
|
|||
RunTime Error 3134
One possibility is your field CurrentUser: that's a reserved word, and so
can lead to problems. (For a great discussion on what names to avoid in Access, see what Allen Browne has at http://www.allenbrowne.com/Ap****ueBadWord.html) For now, try enclosing it in square brackets strSQL = "INSERT INTO tblMovement " & _ "(EmpID, InsertDate, EffectiveDate, [CurrentUser], " & _ "NewSupervisor, NewTitle, NewCenter) " & _ etc If that solves the issue, consider renaming the field (even though that's a lot of work...) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "ajhome" wrote in message ... Good Morning, It tells me the following message: "The INSERT INTO statement contains the following unknown field name: 'NewSupervisor'. When I take that field out, I get the same error message for the other fields as well. I have doubled checked my form and table to make sure that I have spelled everything correctly and the same, and I have. What else could be causing that error? "Douglas J. Steele" wrote: Try changing to: Dim strSQL As String strSQL = "INSERT INTO tblMovement " & _ "(EmpID, InsertDate, EffectiveDate, CurrentUser, " & _ "NewSupervisor, NewTitle, NewCenter) " & _ "VALUES (" & lstSelectEmp.Column(0) & ", " & _ Format(txtInsertDate, "\#yyyy\-mm\-dd\#") & _ "," & Format(txtEffectiveDate, "\#yyyy\-mm\-dd\#") & ", " & _ Chr$(34) & txtCurrent & Chr$(34) & ", " & _ Chr$(34) & cboNewSupervisor & Chr$(34) & ", " & _ Chr$(34) & cboNewTitle & Chr$(34) & ", " & _ Chr$(34) & cboNewCenter & Chr$(34) & ")" Debug.Print strSQL CurrentDb.Execute strSQL, dbFailOnError When the code runs, go to the Immediate Window (Ctrl-G) and look at the SQL string that was written there. Does it look correct? What happens if you create a query, paste that same SQL into it and run it? Does adding the dbFailOnError parameter cause any meaning error to be raised? -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) |
#25
|
|||
|
|||
RunTime Error 3134
I tried, and it still didn't work. I have also changed that field name to
logon. "Douglas J. Steele" wrote: One possibility is your field CurrentUser: that's a reserved word, and so can lead to problems. (For a great discussion on what names to avoid in Access, see what Allen Browne has at http://www.allenbrowne.com/Ap****ueBadWord.html) For now, try enclosing it in square brackets strSQL = "INSERT INTO tblMovement " & _ "(EmpID, InsertDate, EffectiveDate, [CurrentUser], " & _ "NewSupervisor, NewTitle, NewCenter) " & _ etc If that solves the issue, consider renaming the field (even though that's a lot of work...) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "ajhome" wrote in message ... Good Morning, It tells me the following message: "The INSERT INTO statement contains the following unknown field name: 'NewSupervisor'. When I take that field out, I get the same error message for the other fields as well. I have doubled checked my form and table to make sure that I have spelled everything correctly and the same, and I have. What else could be causing that error? "Douglas J. Steele" wrote: Try changing to: Dim strSQL As String strSQL = "INSERT INTO tblMovement " & _ "(EmpID, InsertDate, EffectiveDate, CurrentUser, " & _ "NewSupervisor, NewTitle, NewCenter) " & _ "VALUES (" & lstSelectEmp.Column(0) & ", " & _ Format(txtInsertDate, "\#yyyy\-mm\-dd\#") & _ "," & Format(txtEffectiveDate, "\#yyyy\-mm\-dd\#") & ", " & _ Chr$(34) & txtCurrent & Chr$(34) & ", " & _ Chr$(34) & cboNewSupervisor & Chr$(34) & ", " & _ Chr$(34) & cboNewTitle & Chr$(34) & ", " & _ Chr$(34) & cboNewCenter & Chr$(34) & ")" Debug.Print strSQL CurrentDb.Execute strSQL, dbFailOnError When the code runs, go to the Immediate Window (Ctrl-G) and look at the SQL string that was written there. Does it look correct? What happens if you create a query, paste that same SQL into it and run it? Does adding the dbFailOnError parameter cause any meaning error to be raised? -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) |
#26
|
|||
|
|||
RunTime Error 3134
What are the fields in your tblMovement table?
-- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "ajhome" wrote in message ... I tried, and it still didn't work. I have also changed that field name to logon. "Douglas J. Steele" wrote: One possibility is your field CurrentUser: that's a reserved word, and so can lead to problems. (For a great discussion on what names to avoid in Access, see what Allen Browne has at http://www.allenbrowne.com/Ap****ueBadWord.html) For now, try enclosing it in square brackets strSQL = "INSERT INTO tblMovement " & _ "(EmpID, InsertDate, EffectiveDate, [CurrentUser], " & _ "NewSupervisor, NewTitle, NewCenter) " & _ etc If that solves the issue, consider renaming the field (even though that's a lot of work...) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "ajhome" wrote in message ... Good Morning, It tells me the following message: "The INSERT INTO statement contains the following unknown field name: 'NewSupervisor'. When I take that field out, I get the same error message for the other fields as well. I have doubled checked my form and table to make sure that I have spelled everything correctly and the same, and I have. What else could be causing that error? "Douglas J. Steele" wrote: Try changing to: Dim strSQL As String strSQL = "INSERT INTO tblMovement " & _ "(EmpID, InsertDate, EffectiveDate, CurrentUser, " & _ "NewSupervisor, NewTitle, NewCenter) " & _ "VALUES (" & lstSelectEmp.Column(0) & ", " & _ Format(txtInsertDate, "\#yyyy\-mm\-dd\#") & _ "," & Format(txtEffectiveDate, "\#yyyy\-mm\-dd\#") & ", " & _ Chr$(34) & txtCurrent & Chr$(34) & ", " & _ Chr$(34) & cboNewSupervisor & Chr$(34) & ", " & _ Chr$(34) & cboNewTitle & Chr$(34) & ", " & _ Chr$(34) & cboNewCenter & Chr$(34) & ")" Debug.Print strSQL CurrentDb.Execute strSQL, dbFailOnError When the code runs, go to the Immediate Window (Ctrl-G) and look at the SQL string that was written there. Does it look correct? What happens if you create a query, paste that same SQL into it and run it? Does adding the dbFailOnError parameter cause any meaning error to be raised? -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) |
Thread Tools | |
Display Modes | |
|
|