On my main form I have 2 listboxes - lstUsers, and lstLibraries. I want to be able to select a user from lstUsers, and select a library from lstLibraries, then click a button which will load up my UsersVisits form and subform and allow me to "book" a visit for the selected user and library. The VisitID is an auto number, so every booking will increment to the next VisitID.
I can get the form to display the correct userID and LibraryID, but the subform will not automatically increment on load to the next VisitID, instead it just displays the first VisitID for that particular User.
My button code to load the form and subform for when a user and library is selected in each listbox is as follows (I know it needs altering, and this is where I am stuck) -
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "beneficiary_visits_frm"
stLinkCriteria = "[beneficiaryID]=" & "'" & Me![lst_beneficiaries] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Forms![beneficiary_visits_frm].Form![beneficiary_visits_subform]![beneficiaryID] = Forms!main_frm.lst_beneficiaries.Column(0)
Forms![beneficiary_visits_frm].Form![beneficiary_visits_subform]![centreID] = Forms!main_frm.lst_centres.Column(0)
What do I need to do to allow the VisitID to automatically increase?
It does indeed now automatically increment the VisitID on the UserVisits subform.
But, now there is a problem occuring on the UserVisits form, the libraryID field (textbox) is remaining empty - it is not taking the libraryID field selected in the lstLibraries listbox on the main form when the button is pressed.
So I have an empty UserVisits form, but the UserVisits subform is populated. But of course I cant save the record due to the empty fields on the UserVisits form.