Getting rid of the "do you want to append" message

cstanley

Registered User.
Local time
Today, 10:35
Joined
May 20, 2002
Messages
86
Hello everyone!

I have the following code for a multi-select list box. It worrks great, but for every record, the user has to click "Yes" to the "You are about to add one record" question. How do I get Access to stop asking that? There must be a simple answer.

Thanks!

Chris

Private Sub Command16_Click()
On Error GoTo Err_Command16_Click
Dim varItem As Variant, strSQL As String

For Each varItem In [lstRequirements].ItemsSelected 'Loop through all selected items in the list box'
strSQL = "insert into [tblDesignUserRequirementsJoin] (DUR,[SystemNumber]) values (" & [lstRequirements].ItemData(varItem) & "," & cboSystemNumber & ")"
DoCmd.RunSQL (strSQL) 'Append a record'
Next 'Move to the next item selected in the list box'


Exit_Command16_Click:
Exit Sub

Err_Command16_Click:
MsgBox Err.Description
Resume Exit_Command16_Click

End Sub
 
Private Sub Command16_Click()
On Error GoTo Err_Command16_Click
Dim varItem As Variant, strSQL As String
DoCmd.SetWarnings False

For Each varItem In [lstRequirements].ItemsSelected 'Loop through all selected items in the list box'
strSQL = "insert into [tblDesignUserRequirementsJoin] (DUR,[SystemNumber]) values (" & [lstRequirements].ItemData(varItem) & "," & cboSystemNumber & ")"
DoCmd.RunSQL (strSQL) 'Append a record'
Next 'Move to the next item selected in the list box'
DoCmd.SetWarnings True


Exit_Command16_Click:
Exit Sub

Err_Command16_Click:
MsgBox Err.Description
Resume Exit_Command16_Click

End Sub
 
Merci!

Now, for a harder question... is there a way for it to ask "You are about to append 4 records.... ?"

Thanks,

Chris
 
Before you run your Loop to append do a message on the Count of the Selected Items.

Example:
Code:
If msgbox("Are you sure you want to append " & me.[lstRequirements].ItemsSelected.Count & " records.",vbYesNo+vbQuestion,"Appending Records")=vbNo then Exit Sub
 
doCmd.setwarnings(False)
query here
doCmd.setwanrings(True)
 

Users who are viewing this thread

Back
Top Bottom