Use listbox value to open record in another form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Microsoft has a useful wizard for selecting a record based on a list box value, but it only seems to work if created on the same form. What I'm trying to do is this find a record on another form. Specifically

I have a listox called TenantList on a form called SelectAparment
I want to select a name on TenantList and click on a button that will open a separate form called TenantsForm where the name on the TenantsForm record matches the name in the TenantList listbox

Thanks.
 
Private Sub cmdMyButton_Click()
If Not IsNull(Me!TenantList) Then
DoCmd.OpenForm "TenantsForm", , , "TenantName = """ & Me!TenantList
& """"
End If
End Sub

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html


Carnegie23 said:
Microsoft has a useful wizard for selecting a record based on a list box
value, but it only seems to work if created on the same form. What I'm
trying to do is this find a record on another form. Specifically:
I have a listox called TenantList on a form called SelectAparment.
I want to select a name on TenantList and click on a button that will open
a separate form called TenantsForm where the name on the TenantsForm record
matches the name in the TenantList listbox.
 
Back
Top