G
Greg
Can someone sort out this code for me. I am trying to call a function to
requery a listBox and a subform after a button is clicked but I just can't
seem to get the correct syntax. Thanks!
Private Sub CmdRemoveTube_Click()
Dim RemoveID As Long
Dim ListBoxName As String
Dim SubFormName As String
RemoveID =
[Forms]![Frm_EditBooking]![Sub_SelectedTube]![lng_SelectedEquipmentID]
ListBoxName = "cbo_TubeSelect"
SubFormName = "Sub_SelectedTube"
Call CBF_RemoveEquipment(RemoveID, SubFormName, ListBoxName)
End Sub
Private Sub CBF_RemoveEquipment(RemoveID As Variant, SubFormName As SubForm,
ListBoxName As ListBox)
On Error GoTo CBF_RemoveEquipment_ERR
Dim strsql As String
If IsNull(RemoveID) Then
Exit Sub
End If
DoCmd.SetWarnings False
strsql = "Delete * FROM Tbl_Wrk_SelectedEquip " _
& "WHERE lng_SelectedEquipmentID = " & RemoveID
DoCmd.RunSQL strsql
DoCmd.SetWarnings True
Me!SubFormName.Form.Requery
Me!ListBoxName.Requery
fDataChanged = True
Exit Sub
CBF_RemoveEquipment_ERR:
Call Error_Handler(False)
Exit Sub
End Sub
requery a listBox and a subform after a button is clicked but I just can't
seem to get the correct syntax. Thanks!
Private Sub CmdRemoveTube_Click()
Dim RemoveID As Long
Dim ListBoxName As String
Dim SubFormName As String
RemoveID =
[Forms]![Frm_EditBooking]![Sub_SelectedTube]![lng_SelectedEquipmentID]
ListBoxName = "cbo_TubeSelect"
SubFormName = "Sub_SelectedTube"
Call CBF_RemoveEquipment(RemoveID, SubFormName, ListBoxName)
End Sub
Private Sub CBF_RemoveEquipment(RemoveID As Variant, SubFormName As SubForm,
ListBoxName As ListBox)
On Error GoTo CBF_RemoveEquipment_ERR
Dim strsql As String
If IsNull(RemoveID) Then
Exit Sub
End If
DoCmd.SetWarnings False
strsql = "Delete * FROM Tbl_Wrk_SelectedEquip " _
& "WHERE lng_SelectedEquipmentID = " & RemoveID
DoCmd.RunSQL strsql
DoCmd.SetWarnings True
Me!SubFormName.Form.Requery
Me!ListBoxName.Requery
fDataChanged = True
Exit Sub
CBF_RemoveEquipment_ERR:
Call Error_Handler(False)
Exit Sub
End Sub