Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP ON OPEN ARGS PROPERTY 1

Status
Not open for further replies.

desikan

Technical User
Feb 2, 2001
105
AE
I have a Form "Form1" with an command button having following on click code :

DoCmd.OpenForm "Form2", acNormal, , , acFormEdit, acWindowNormal, CARD.Value

On Form2, I have following code on "OnOpen" function and I get the value of "card" on "text48":
DoCmd.GoToRecord , , acNewRec
Text48.SetFocus
Text48.Text = Me.OpenArgs

Now I want to transport the value of one more field "qty" from Form1 to Form2. I could not find any help from MS Access Help and hence temporarily I have set up a combo box in Form2 which has in its Row source "qty" from Form1 but the user has to open the combo box every time.

I there any other way to get value of 2 fields across to Form2 automatically?

Thanks in advance for all ideas.


 
desikan
One way you should be able to do it is this...

Put an additional line in your code behind the command button on Form1, following the line that says
DoCmd.OpenForm "Form2", acNormal, , , acFormEdit, acWindowNormal, CARD.Value

That additional line would read
Forms!Form2!YourFieldName = Me.qty

Hope that helps.

Tom

 
Thanks for your reply, Tom.
I could not believe it but your simple solution worked fine.
Thank you very much.

I have a small question though. i had put set focus on 1 field of Form2 but how did the 2nd field data come through without declaring set focus?

If my question is too elementary, please forgive me.

Thanks
 
Hi Tom,
I am sorry. There was a small mistake. For testing purpose, I had created Corm2 as an unbound form and your solution worked fine. But when I made it as a bound form then I am getting the error "You can't assign value to this object".

I am trying to get a clue. I will come back to you when I get through.

Thanks
 
Hi Tom,
I think today was not a good day for me and I am making too many mistakes.

I made a small mistake in naming the boundfield in Form2 and hence I was getting the error message. Sorry to test your patience.

Perhaps now you can explain about set focus on the 2 fields?

Thanks once again
 
desikan
We have been away for a while and just returned home.

The data transports from Form1 to Form2 irrespective of where the focus is set in Form2 when it opens.

Where do you want the focus to go when Form2 opens? Wherever that is, put an additional line behind the command button on Form1.

Following the
Forms!Form2!YourFieldName = Me.qty
put
Forms!Form2!YourFieldName.SetFocus

That should do it.

Tom
 
Thanks Tom for your reply and the time you have taken forme.

And before it is too late may I wish you a very happy Christmas!!
 
desikan
Glad things worked.

A belated Happy Christmas to you as well.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top