I have a mainform for a new camping reservation, with a subform for entering a new contact upon making a new reservation. I also have a subform for editing a contact on-the-run when making a new reservation.
I've become a bit confused, however, as to whether I'm organizing it correctly, and I plain wonder how to update the respective fields after entry.
I have the following (relevant) tables:
BOOKINGS
--ID, ContactID, RoomID, Time...etc
CONTACTS
--ID, LastName, FirstName, Mobile...etc
ROOMS
--ID, RoomNumber...et c
and the following (relevant) forms:
FORM18 *
-RecS is a query with the three above tables connected
-it has comboboxes with ContactID, LastName, FirstName, where the user can find a contact and the rest is filled in. (all working fine.)
-another combobox for RoomID
*(it's actually QUERY18 in the code, excuse the name, im hesitant to change it before i have working code! =)
then buttons to start up subforms for 1) entering new contact on-the-run, 2) editing existing contact on-the-run.
SUBFORM1 (new contact)
-recS is a query with only CONTACTS form
-this works with creating new contacts and updating main form
SUBFORM2 (edit)
-recS is a query with only CONTACTS form
-i cant figure out how to update the main form with it...
this is the code for pressing the Edit Contact button in main form:
Expand|Select|Wrap|Line Numbers
- Private Sub Command375_Click()
- 'Edit contact info button
- 'cefLN = Form_Query18.ctlContactEditForm.Form!LastName.Value
- 'Forms!Mainform!Subform1.Form!Subform2.SourceObject
- idContact = Me.ContactID.Value
- MsgBox "contactID = " & idContact
- cefLN = Me!ctlContactEditForm!LastName.Value
- cefLN2 = Forms!Query18!ctlContactEditForm!FirstName.Value
- MsgBox cefLN & ", " & cefLN2
- Form_Query18.ctlContactEditForm.Visible = True
- 'Form_Query18!ctlContactEditForm.Form!ContactID.Value = editID
- 'Form_ContactEditForm.ID.Value = editID
- End Sub
Expand|Select|Wrap|Line Numbers
- :
- Private Sub Form_Load()
- 'Me.ContactID.Value = 1
- Set rstBookings = CurrentDb.OpenRecordset("Contacts", dbOpenTable)
- With rstBookings
- returnID = !ID
- End With
- MsgBox returnID
- End Sub
2) i'm not able move to the correct contact when opening the subform that edits existing contacts!
3) when i call OpenRecordset, for "Contacts" for example, does that go for all comboboxes that are connected to Contacts? or just for the current form?
4) and how to move the combobox recordset on the subform to the same position as on the mainform for Contacts?
sorry about rather longish question, just hope i havent left anything out.
thank you very much for any help...