P
perryclisbee via AccessMonster.com
Hi,
Below is a sample of code from one of my command buttons. Each button
currently has this code. I want to simplify the process by making a function
that the cmdbuttons can call. However, the one section that is hardcoded per
button is:
Me!txtGrid.Value = "A2"
I have about 50 cmdbuttons on this form, all with the same code. I need the
txtGrid value to be equal to the gridname of the cmdbutton. Is there some
code that will recognize the name of the cmdbutton clicked? That way I could
just make one function that each button will call to when clicked on. I need
it this way because by clicking on the button, I pull up a data entry screen
with button specific (IE: A2) information on it...
Thanks,
Perry
Private Sub cmdA2_Click()
Dim stDocName As String
Dim stLinkCriteria As String
txtProductSold.Value = "0"
txtProductExpired.Value = "0"
Me!txtGrid.Value = "A2"
Me!txtProduct = DLookup("product", "qryCellProduct")
Me!txtQuantitySet = DLookup("SetQuantity", "qryCellProduct")
Me!txtShadowProduct.Value = Me![txtProduct]
Me!txtShadowQuantitySet.Value = Me![txtQuantitySet]
Me!txtShadowDate.Value = Me![Date]
stDocName = "frmVendingMachineCell"
DoCmd.OpenForm stDocName
Forms!frmVendingmachineCell!txtProductShadow = DLookup("product",
"qryCellProduct")
Forms!frmVendingmachineCell!txtQuantitySet = DLookup("SetQuantity",
"qryCellProduct")
Forms!frmVendingmachineCell!txtGridShadow = Forms!frmVendingmachine!
txtGrid
Forms!frmVendingmachineCell!txtDateShadow = Forms!frmVendingmachine!
txtShadowDate
End Sub
Below is a sample of code from one of my command buttons. Each button
currently has this code. I want to simplify the process by making a function
that the cmdbuttons can call. However, the one section that is hardcoded per
button is:
Me!txtGrid.Value = "A2"
I have about 50 cmdbuttons on this form, all with the same code. I need the
txtGrid value to be equal to the gridname of the cmdbutton. Is there some
code that will recognize the name of the cmdbutton clicked? That way I could
just make one function that each button will call to when clicked on. I need
it this way because by clicking on the button, I pull up a data entry screen
with button specific (IE: A2) information on it...
Thanks,
Perry
Private Sub cmdA2_Click()
Dim stDocName As String
Dim stLinkCriteria As String
txtProductSold.Value = "0"
txtProductExpired.Value = "0"
Me!txtGrid.Value = "A2"
Me!txtProduct = DLookup("product", "qryCellProduct")
Me!txtQuantitySet = DLookup("SetQuantity", "qryCellProduct")
Me!txtShadowProduct.Value = Me![txtProduct]
Me!txtShadowQuantitySet.Value = Me![txtQuantitySet]
Me!txtShadowDate.Value = Me![Date]
stDocName = "frmVendingMachineCell"
DoCmd.OpenForm stDocName
Forms!frmVendingmachineCell!txtProductShadow = DLookup("product",
"qryCellProduct")
Forms!frmVendingmachineCell!txtQuantitySet = DLookup("SetQuantity",
"qryCellProduct")
Forms!frmVendingmachineCell!txtGridShadow = Forms!frmVendingmachine!
txtGrid
Forms!frmVendingmachineCell!txtDateShadow = Forms!frmVendingmachine!
txtShadowDate
End Sub