One form to another

B

bladelock

I have a form (called frmLogon) that a user selects from a combo box their
name(called cboName) after they select it, they press a command button on the
form and it closes the logon form and displays a new input form (call
frmInput). What I really need is to store the combo box (cboName) selected
name on form (frmLogon) to a field (text.User)on my input form (frmInput).
Thanks you all.
 
6

'69 Camaro

Hi.

In the frmLogon procedure that opens the frmInput form, try code such as the
following:

DoCmd.OpenForm "frmInput", , , , , , Me!cboName.Column(1)

.... where Column(1) is number of the column that displays the value in the
combo box.

In the frmInput form's Form_Open( ) event, try the following code:

If (Len(Me.OpenArgs) > 0) Then
Me!txtUser.Value = Me.OpenArgs
End If

.... where txtUser is the text box holding the user name.

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)

- - -
When you see correct answers to your question posted in Microsoft's Online
Community, please sign in to the Community and mark these posts as "Answers,"
so that all may benefit by filtering on "Answered questions" and quickly
finding the right answers to similar questions. Remember that questions
answered the quickest are often from those who have a history of rewarding
the contributors who have taken the time to answer questions correctly.
 
R

Roger Carlson

You could do this two ways:
1) Use the Openargs property to pass the value to the new form. On my
website (), is a small Access database sample called: "Openargs2k.mdb" that
illustrates how to do this.

2) Don't close the Logon form, just hide it. Then you can reference the
control on the form at any time. As long as the form is open (even if it's
hidden) you can reference it. Something like this:
=Forms!frmLogon!cboName

--
--Roger Carlson
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 
B

bladelock

I hide the form and it works, but, it only works for one record. I want the
user to keep adding new records (on the input form) and when they click "add
record" the user name become #Error. I put "=Forms!frmLogon!cboName" in the
User Text box as a default
 
R

Roger Carlson

OK. "=Forms!frmLogon!cboName" in the control source of a textbox just
displays the field in the record. You can't put that in the Default Value
property either. If you want to assign it to a bound control, you have to
assign it in code. There are a number of ways and times to do this. One
way would be to put something like this in the OnCurrent Event:

If IsNull(txtUser) Then
txtUser = Forms!frmLogon!cboName
End If

Any time you go to a record without a value in txtUser (assuming that's the
name of the bound textbox), it will be assigned the value from your hidden
form.

OR

If Me.NewRecord Then

txtUser = Forms!frmLogon!cboName
End If

Any time you go to a New Record, the value from the hidden form will be
assigned.

Either way, you must ALWAYS have this form open (hidden or not) when you
access this form. Otherwise you will get an error.

--
--Roger Carlson
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 
B

bladelock

Thank you Very Much!!

Roger Carlson said:
OK. "=Forms!frmLogon!cboName" in the control source of a textbox just
displays the field in the record. You can't put that in the Default Value
property either. If you want to assign it to a bound control, you have to
assign it in code. There are a number of ways and times to do this. One
way would be to put something like this in the OnCurrent Event:

If IsNull(txtUser) Then
txtUser = Forms!frmLogon!cboName
End If

Any time you go to a record without a value in txtUser (assuming that's the
name of the bound textbox), it will be assigned the value from your hidden
form.

OR

If Me.NewRecord Then

txtUser = Forms!frmLogon!cboName
End If

Any time you go to a New Record, the value from the hidden form will be
assigned.

Either way, you must ALWAYS have this form open (hidden or not) when you
access this form. Otherwise you will get an error.

--
--Roger Carlson
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 
Top