ok I have Form with buttons I'd like to hide after an update query runs.
I want to use the same code on another form; I do not want to repeat the code; I know that I can use the code in Public function and call the function when the command button is clicked.
My problem is that the forms have different names and I am using the Me. in the code. How can I overcome these two issues? (I got this part solved)
how would I refence the button in the module?
I want to use the same code on another form; I do not want to repeat the code; I know that I can use the code in Public function and call the function when the command button is clicked.
My problem is that the forms have different names and I am using the Me. in the code. How can I overcome these two issues? (I got this part solved)
how would I refence the button in the module?
Code:
form1
Private Sub cmdSQL_Click()
RunUpdate Me.CustomerID
Forms!CustomerF.Refresh
End Sub
Form2
Private Sub cmdSQL_Click()
RunUpdate Me.CustomerID
Forms!Customers.Refresh
End Sub
module
Public Sub RunUpdate(ByVal Cid)
Dim A As String
DoCmd.SetWarnings False
A = "UPDATE CustomerT Set CustomerT.IsActive = true " _
& "WHERE CustomerT.CustomerID=" & Cid & ""
DoCmd.RunSQL A
DoCmd.SetWarnings True
End Sub