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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

INSERT prompts parameter

Status
Not open for further replies.
Jul 15, 2002
17
US
I am running the following code on an Office XP database in Office 2000 file format:

Private Sub AccountManager_AfterUpdate()
Dim strDLR As String
Dim strSQL As String
Dim strAcct As String
Dim strDate As String

strDate = Format(Date, mm - DD - yyyy)
strAcct = Me.AccountManager.Value
strDLR = Me.DLR_NUM.Value
strSQL = "INSERT INTO DealerRepLog (ChangeDate, Dealer, NewAcctRep) VALUES (" & strDate & ", " & strDLR & ", " & strAcct & ")"

DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
End Sub

When I run the event, I get a enter parameter box. The message in the parameter box is the correct value of strDLR. The value entered into this box is then inserted into the Dealer field of the table. I am confused as to why it is behaving this way. Thanks in advance.

Chris Haufschild
chaufschild@hotmail.com
 
Chris,

I would try:

VALUES (#" & strDate & "#, " & strDLR & ", " & strAcct & ")"

to bracket the date. I also like the direct methid for adding values. At times like this you can then use debug.print and msgbox to see what is going on. INSERTS are, in my opinion, trickier than they should be. Do you need code for the direct insert?


Rollie E
 
I guess I am not sure of what you mean by direct inserts. If you would post that code that would be great.

Chris
 
dim rs as doa.recordset
set rs = currentdb.openrecordset("MyTable")
rs.addnew
rs.fields(1) = StrValu1
rs.fields(2) = StrValu2
rs.fields(3) = StrValu3
rs.update
rs.close
set rs = nothing
me.requery

Rollie E
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top