If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Opening a Form and Getting Value on A Click Event
It has been a while since I done much Access VBA. I have a form
(frmInspectionDetail) to collect inspection data. On that form there is a button that opens another form (frmPanel) that has several command buttons that represent the items being inspected. I need to be able to click on one of the items and have a variable associated with that item (found in a table) passed back to the original calling form (frmInspectionDetail), which will still be open. I am not sure of the approach. In general I guess I need the command button on the first form to launch some type of function that awaits the value from the second form to be passed back so it can catch it. Thanks for any ideas on how to do this? |
#2
|
|||
|
|||
Opening a Form and Getting Value on A Click Event
There is a better way. Rather than opening a second form and passing data
back and forth, you could create a Combo Box control on your first form that would give you a list of all the items being inspected. Then when you select an item from that list, use the After Update event of the Combo Box to retrieve the data from the table and put it in your text box. Here is an example of how that could work. Of course you will have to change the code to use your own names, etc: Private Sub cboItemList_AfterUpdate() Dim varItem as Variant On Error GoTo cboItemList_AfterUpdate_Error If Not IsNull(Me.cboItemList) Then varItem = DLookup("[SomeField]", "SomeTable", "[Field to Match] = '" _ & Me.cboItemList & "'" If IsNull(varItem) Then MsgBox "Can't Find That Item" Else Me.SomeTextBox = varItem End If End If cboItemList_AfterUpdate_Exit: On Error Resume Next Exit Sub "Cliff" wrote: It has been a while since I done much Access VBA. I have a form (frmInspectionDetail) to collect inspection data. On that form there is a button that opens another form (frmPanel) that has several command buttons that represent the items being inspected. I need to be able to click on one of the items and have a variable associated with that item (found in a table) passed back to the original calling form (frmInspectionDetail), which will still be open. I am not sure of the approach. In general I guess I need the command button on the first form to launch some type of function that awaits the value from the second form to be passed back so it can catch it. Thanks for any ideas on how to do this? |
#3
|
|||
|
|||
Opening a Form and Getting Value on A Click Event
I explain here how to do this he
http://www.members.shaw.ca/AlbertKal...log/Index.html -- Albert D. Kallal (Access MVP) Edmonton, Alberta Canada http://www.members.shaw.ca/AlbertKallal |
Thread Tools | |
Display Modes | |
|
|