Adding new listposts (1 Viewer)

hhag

Member
Local time
Today, 14:05
Joined
Mar 23, 2020
Messages
69
When I add data to a new record in a form (tblOffer) I use a combox (tblContact) to choice contact to each record. It happens when I choice contact that the name doesn’t exist. In order to add a new contact I need today to leave the form and go to another form in order to add this new contact and connect the contact to a specific customer (tblCustomer). Then, turning back to a new form, I’ve lost all edited data and I need start a new record in tblOffer. It’s this that becomes tricky for me.
Does anyone have a solution how you stay in the first record, and then make it possible to both add a new contact (via the combobox I use today) and connect this contact to an existing customer name (via a possible new combobox)? I do believe I could open the Customer/Conatct form and add the new contact and then go back to the new record in tblOffer that I started off with. But how?

I’ve these tables:

tblOffer
tblContact (This has a one-to-many relation to tblOffer)
tblCustomer (This has a one-to-many relation to tblContact)


It would be nice to add all contact info to the new contact as well as company info.

Would be extremely happy for some tips.
 

Isaac

Lifelong Learner
Local time
Today, 05:05
Joined
Mar 14, 2017
Messages
8,777
Why can't you just open the new form and leave the form you were on, open?
 

Gasman

Enthusiastic Amateur
Local time
Today, 13:05
Joined
Sep 21, 2011
Messages
14,305
You could use the NotInList event ?

Code:
Private Sub CMS_NotInList(NewData As String, Response As Integer)
Dim ctl As Control
Set ctl = Me.CMS

If MsgBox("CMS ref is not in client table? Add it", vbOKCancel) = vbOK Then
    DoCmd.OpenForm "frmClient", , , , , acDialog, Me.CMS.Text
    Response = acDataErrAdded
Else
    Response = acDataErrContinue
    ctl.Undo
End If

Set ctl = Nothing

End Sub
 

theDBguy

I’m here to help
Staff member
Local time
Today, 05:05
Joined
Oct 29, 2018
Messages
21,473
Hi. You might also investigate using the List Items Edit Form property of the Combobox.
 

hhag

Member
Local time
Today, 14:05
Joined
Mar 23, 2020
Messages
69
Thanks for feedback. I'll test a little.
I use a navigation form for walking around among the forms and task I want to do. Can I then get back to the form that I use for registration of new records and get back to this specific record I started with?
When I switch from one form to another, the form is closed I believe. And when I then go back to complete the data, I come to a new record. And I get incomplete records in the table.
Well, I'm a beginner so....
 

Isaac

Lifelong Learner
Local time
Today, 05:05
Joined
Mar 14, 2017
Messages
8,777
When I switch from one form to another, the form is closed I believe
Well, I don't use Navigation Forms in access, but I'm 86% sure that no matter whether you do or don't, opening and closing forms is a matter of how you are coding them. If your code says "close this form and open another", well then you are closing the original form. What I am suggesting is that you adjust your code (wherever you have the code that 'switches' forms), to simply no longer close one and open another, but rather, just open another.
 

Micron

AWF VIP
Local time
Today, 08:05
Joined
Oct 20, 2018
Messages
3,478
I'm 86% sure that no matter whether you do or don't, opening and closing forms is a matter of how you are coding them.
That would be 86% incorrect. A navigation subform loads a form into its navigation subform control, which means you can only have one form open at a time. Open one, whatever other form was opened gets closed. To pass values from one to another in this situation requires a work-around. Maybe module level variables, maybe global, maybe BrowseTo method, but I don't really know because I've never used a nav form beyond what it takes to help people solve their issues with them.
 

Isaac

Lifelong Learner
Local time
Today, 05:05
Joined
Mar 14, 2017
Messages
8,777
That would be 86% incorrect. A navigation subform loads a form into its navigation subform control, which means you can only have one form open at a time. Open one, whatever other form was opened gets closed. To pass values from one to another in this situation requires a work-around. Maybe module level variables, maybe global, maybe BrowseTo method, but I don't really know because I've never used a nav form beyond what it takes to help people solve their issues with them.
LOL - ok, I stand corrected. Thanks for explaining me.
With the old Switchboard forms, I know that it would have been possible to edit the code behind the switchboard, so I would have assumed the same was possible with Navigation forms, but like I said …. I never have used them.

And this experience confirms that I wouldn't want to start. :)
 

Users who are viewing this thread

Top Bottom