A
Angi
This is too weird. This is pretty straight forward...assign an invoice
# and then append to the InvoiceMain table. It assigns the # and runs
through the code with no errors, but it doesn't append the InvoiceMain
table. If I do it through a query instead of Sql, it works fine. The
only thing I can see that's different is that i'm using the me.quoteid
instead of the forms!... But when I put a break in the code, the
me.quoteid value is right so I should be able to use that syntax,
right?? I have code just like this elsewhere in my db and haven't had
a problem. What am I doing wrong?
Private Sub cmdOrder_Click()
Dim sql As String
If IsNull(Me.InvoiceID) Then
Me.InvoiceID = Nz(DMax("invoiceid", "invoicemain"), 2000) + 1
'create invoice
sql = "INSERT INTO InvoiceMain ( CoID, InvoiceID, ContactID,
ShippingMethodID, FreightAmt, ReqDate, InvoiceNotes ) " _
& "SELECT QuoteMain.CoID, QuoteMain.InvoiceID,
QuoteMain.ContactID, QuoteMain.ShippingMethodID, QuoteMain.FreightAmt,
QuoteMain.ReqDate, QuoteMain.QuoteNotes " _
& "FROM QuoteMain WHERE (((QuoteMain.QuoteID)=" & Me.QuoteID &
"));"
CurrentDb.Execute sql, dbfailonerror
End If
End Sub
TIA!
Angi
# and then append to the InvoiceMain table. It assigns the # and runs
through the code with no errors, but it doesn't append the InvoiceMain
table. If I do it through a query instead of Sql, it works fine. The
only thing I can see that's different is that i'm using the me.quoteid
instead of the forms!... But when I put a break in the code, the
me.quoteid value is right so I should be able to use that syntax,
right?? I have code just like this elsewhere in my db and haven't had
a problem. What am I doing wrong?
Private Sub cmdOrder_Click()
Dim sql As String
If IsNull(Me.InvoiceID) Then
Me.InvoiceID = Nz(DMax("invoiceid", "invoicemain"), 2000) + 1
'create invoice
sql = "INSERT INTO InvoiceMain ( CoID, InvoiceID, ContactID,
ShippingMethodID, FreightAmt, ReqDate, InvoiceNotes ) " _
& "SELECT QuoteMain.CoID, QuoteMain.InvoiceID,
QuoteMain.ContactID, QuoteMain.ShippingMethodID, QuoteMain.FreightAmt,
QuoteMain.ReqDate, QuoteMain.QuoteNotes " _
& "FROM QuoteMain WHERE (((QuoteMain.QuoteID)=" & Me.QuoteID &
"));"
CurrentDb.Execute sql, dbfailonerror
End If
End Sub
TIA!
Angi