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

Run cmd action on Form Submit

Status
Not open for further replies.

glenmac

Technical User
Jul 3, 2002
947
0
0
CA
I have a form with cmd button on it that inserts value in a table. Is there a way to have the value in the same record the form creates when submitted. As it stands now 2 records are created one from the form and one from the cmd button. I need to input the values in the same record.
here's the code from the cmd button.
Code:
Private Sub Command36_Click()

On Error GoTo Err_Command36_Click

For Each num In List37.ItemsSelected
var = var & List37.ItemData(num) & "_"
Next
If Len(var) > 0 Then
DoCmd.RunSQL "insert into Orders (Custom_Ingedients) values ('" & Left(var, Len(var) - 1) & "')"
'MsgBox var
End If



Exit_Command36_Click:
    Exit Sub

Err_Command36_Click:
    If (Err = ERR_OBJNOTEXIST) Or (Err = ERR_OBJNOTSET) Then
      Resume Next
    End If
    MsgBox Err.Description
   Resume Exit_Command36_Click
    
End Sub
All help will be greatly appreciated !!
 
Can you help me assign a variable to this statement? Then I want to use that variable in the update statement.
CurrentDb.Execute "SELECT Max([Order_ID]) FROM Orders;"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top