daSpud
08-04-2018, 02:01 AM
I have a table with names and addresses. I want to be able to select out those with a given house number (say 1511). Some numbers have only one house (3868) and some have 2 (1511). If there is only 1 then I can go straight to my next form to edit that table entry. If there is more than one then I want to have a form that shows those names and addresses and allow the user to pick the proper one for the edit.
In addition to the house number search I also have a name search that I want to use that same secondary form when there are more than one name match (say "Jones" or "Smith").
The case for 1 works just fine. How do I do the other case? I don't want to make a query on this new form because it can be used for different search results.
frmMultipleLots contains a listbox that I am trying to get the results into so the user can select the correct record.
The way this is now I get all 179 records listed in the listbox. At one point the listbox contained all the records, but the record count at the bottom had the correct record count of 2. Not sure what I changed to get that, but never had only 2 records in the listbox.
Thank you very much for any help.
Dim RecordCount As Long
DocName = "frmHomeOwner"
RecordCount = DCount("Lot_No", "tblHomeOwner", "[First_Street_Number] LIKE '" & [TextIn] & "*' ")
If RecordCount = 1 Then
DoCmd.OpenForm DocName, , , "[First_Street_Number] LIKE '" & [TextIn] & "*' "
Else
MsgBox RecordCount & " houses with number " & TextIn
DoCmd.OpenForm "frmMultipleLots", , , "[First_Street_Number] LIKE '" & Forms![frmOwnerListByLot]![TextIn] & "*' "
End If
In addition to the house number search I also have a name search that I want to use that same secondary form when there are more than one name match (say "Jones" or "Smith").
The case for 1 works just fine. How do I do the other case? I don't want to make a query on this new form because it can be used for different search results.
frmMultipleLots contains a listbox that I am trying to get the results into so the user can select the correct record.
The way this is now I get all 179 records listed in the listbox. At one point the listbox contained all the records, but the record count at the bottom had the correct record count of 2. Not sure what I changed to get that, but never had only 2 records in the listbox.
Thank you very much for any help.
Dim RecordCount As Long
DocName = "frmHomeOwner"
RecordCount = DCount("Lot_No", "tblHomeOwner", "[First_Street_Number] LIKE '" & [TextIn] & "*' ")
If RecordCount = 1 Then
DoCmd.OpenForm DocName, , , "[First_Street_Number] LIKE '" & [TextIn] & "*' "
Else
MsgBox RecordCount & " houses with number " & TextIn
DoCmd.OpenForm "frmMultipleLots", , , "[First_Street_Number] LIKE '" & Forms![frmOwnerListByLot]![TextIn] & "*' "
End If