Close form, how to pass value back to the next form

brianstorm

New member
Local time
Today, 13:56
Joined
Sep 18, 2009
Messages
3
Hi,

I have a form (lets call it events) which references customers.. they can be selected from a combo box... i have added a button to this form "add new customers" which opens my customers form at a data entry page.

I have managed to add a close from button to this customers form (here's the vba).
------------------------------------

Private Sub Close_Customers_Form_Click()
On Error GoTo Err_Close_Customers_Form_Click


DoCmd.Close

Exit_Close_Customers_Form_Click:
Exit Sub

Err_Close_Customers_Form_Click:
MsgBox Err.Description
Resume Exit_Close_Customers_Form_Click

End Sub
------------------------

What I'd like to do is to pass the newly entered customerID back to the original form so that it is the selected customer there.

Can anyone advise me as to how I might do this? Or if there a better way. I am going to have to repeat this type of action several times and I think it would improve usability a great deal.


Apologies if I have posted in the wrong forum.... not sure if this is a VBA or form question.


Many Thanks


Brian
 
Move the original form to the required record before the Input form is closed.
Include a search Public sub in the original form. Call it from the input form OnClose event. This triggers before teh form closes.

BTW. Another way to pass values is to declare a Public variable in a Standard Module of your project. Set the variable as required and then read it back any time you want.
 
hi,

thanks very much for the reply... don't suppose you could help me with the code? i'm not great at vba and googling didn't help me much....

thanks again


brian
 
here is a fabulous "not in list" sample database i found some time ago (june last year, in fact!)

it shows you how to handle all that 'floating' data (like new ID's, new data that isn't in the list etc).

most of what i know about 'not in list' is from this one single database.

unfortunately, i can't remember who posted it and i can't find the original post/thread, but i did save the document when i first saw it :) if it's yours (anyone who's reading my current post), please let me know so i may properly reference the code!

find it attached. you can view the VBA by clicking the "event procedure" ellipsis ("...") button in the properties of the form in design view. the VBA most pertinent to your question would be in the "unload" event of the "frmAddClient" form.

HTH
 

Attachments

hi,

thanks very much for the reply... don't suppose you could help me with the code? i'm not great at vba and googling didn't help me much....

thanks again


brian

did the examples we gave you help? do you require any more assistance?
 
hi,

thanks very much for the examples..i've been sidetracked the last few days but i'll be looking at this again this week, hopefully you have given me the info i need to complete my project...

thanks again... very much apprecciated!

brian
 

Users who are viewing this thread

Back
Top Bottom