UPDATE Statement

  • Thread starter Thread starter Nadine Sinclair via AccessMonster.com
  • Start date Start date
N

Nadine Sinclair via AccessMonster.com

Hi -

I have the following code....oh - I am also a newbie to all of this.

I am creating a new record in the Deposits table. I need the new
Autonumber that was generated by doing this - which I will update the
associated records in the Receipts table. I am getting the problem on the
UPDATE statement. The statement is not recognizing my variable -
intDeposit. Any help at all would be so appreciated!!!!!
**********************************************************************
Private Sub Generate_Deposit_Slip_Click()

Dim SQLString As String
Dim result As Variant
Dim intDeposit As Integer

result = MsgBox("Proceed to Generate Bank Deposit?", vbOKCancel)

If (result = 1) Then
DoCmd.RunSQL "Insert INTO [Deposits]([Deposit_Date]) VALUES (Date());"
intDeposit = DMax("[Deposit_Number]", "[Deposits]")

SQLString = "UPDATE Receipts SET Deposit_Number = intDeposit"
DoCmd.RunSQL SQLString

End If
***********************************************************************

Thanks.

N.
 
Hi -

I have the following code....oh - I am also a newbie to all of this.

I am creating a new record in the Deposits table. I need the new
Autonumber that was generated by doing this - which I will update the
associated records in the Receipts table. I am getting the problem on the
UPDATE statement. The statement is not recognizing my variable -
intDeposit. Any help at all would be so appreciated!!!!!
**********************************************************************
Private Sub Generate_Deposit_Slip_Click()

Dim SQLString As String
Dim result As Variant
Dim intDeposit As Integer

result = MsgBox("Proceed to Generate Bank Deposit?", vbOKCancel)

If (result = 1) Then
DoCmd.RunSQL "Insert INTO [Deposits]([Deposit_Date]) VALUES (Date());"
intDeposit = DMax("[Deposit_Number]", "[Deposits]")

SQLString = "UPDATE Receipts SET Deposit_Number = intDeposit"
DoCmd.RunSQL SQLString

End If
***********************************************************************

Thanks.

N.

SQLString = "UPDATE Receipts SET Deposit_Number = " & intDeposit &
";"
 
Thank you so much for getting back to me. I made the change and it worked!
 
Back
Top