populating a text box from another form

poporacer

Registered User.
Local time
Today, 11:03
Joined
Aug 30, 2007
Messages
136
I have a form that when someone enters data that is not in a combobox (cmbLogNum) the NotInList event is used to open a new form (frmAddIncident). I want a text box (txtIncident) in the current form to be populated by the data from the combobox (cmbLogNum) on the first form (frmEdit).

I used the following code in the OnOpen event and OnLoad event. but it didn't work. I am sure it is something simple, but I can't figure it out.

Me.txtIncident = Forms!frmEdit!cmbLogNum.Column(0)

I also tried Me.txtIncident = Forms![frmEdit]!cmbLogNum.Column(0)

I attached the file.
Thanks in advance
 

Attachments

Try passing the new data as OpenArgs, please see attached.

Regards,
Chris.
 

Attachments

Thanks, both methods worked but created another problem. Here are the issues with each one.
Chris0--- The Open Args works but when the form closes, the combobox is not updated with the new information. I tried to do a Requery on the combobox in the NotInList event and upon exiting the subroutine. Both ways I got an error that stated "You must save the current field before you run the requery action" I am not sure how to fix this?

Uncle Gizmo-- the transfer method works great but when you close the input form you get an error message that states " Application defined error" It appears that in the NotInList code reloads and is tring to get the data and put it on the input form (that was just closed).....I am stumped
Again, thanks for all your help!
 

Attachments

Last edited:
I would suggest that you stop adding any more features and get what you now have to point where it would compile with Option Explicit turned on.

New demo attached.
 

Attachments

ChrisO,
I don't quite understand what you are telling me to do. It appears that is is working right Thanks. Please give me input on what you told me I should do!
you have been a great help!
 
What I mean is that at this stage you should cleanup what you already have.

Option Explicit should be at the top of each module.
Open a module go to Tools > Options > Editor and check ‘Require Variable Declaration’

Compile your code: In a module go to Debug and select Compile.

In some places in the code you have things like: -

Me.MyTextBox.SetFocus
SomethingOrOther = Me.MyTextBox.Text

You don’t need that and it clutters up the code, try just: -

SomethingOrOther = Me.MyTextBox

And there are other things as well, so just getting something to work is only the first step.

Regards,
Chris.
 

Users who are viewing this thread

Back
Top Bottom