Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...This site is like first coffee in the winter morning..."

Geography

Where in the world do Tek-Tips members come from?
ojasg (TechnicalUser)
7 Aug 12 14:12
I have two forms, both connected to the same table.
On closing FormB, I would like to pass a field value as OpenArgs to FormA, and Open FormA

On Opening FormA, I would like to go to that record in FromA which as the FieldValue = OpenArgs, and directly display this specific record only, out of the several.

I have tried several iterations and failed.

Please Help Out!

Thank You!
dhookom (Programmer)
7 Aug 12 19:15
I wouldn't use the OpenArgs. I think the WHERE CONDITION is more appropriate.

CODE

Dim strWhere as String
strWhere = "[NumericFieldName]=" & Me.txtNumericField
DoCmd.OpenForm "FormB", , , strWhere 
If the field is text, try:

CODE

Dim strWhere as String
strWhere = "[TextFieldName]=""" & Me.txtTextField & """ "
DoCmd.OpenForm "FormB", , , strWhere 

Duane
Hook'D on Access
MS Access MVP

ojasg (TechnicalUser)
8 Aug 12 12:39
I keep getting error.
TWONumber is an AutoNumber.

I have what you suggested in addition to this -->

strWhere = TWONumber.Value

DoCmd.OpenForm "frmToolingWorkOrderDuplicate", , , strWhere

It's not working. I get this error -->

"You can't reference a property or method for a control unless the control has focus"

Please let me know how I can fix this.
Is it because of AutoNumber?
dhookom (Programmer)
8 Aug 12 13:38
Why doesn't your strWhere equal something like I suggested? You have a single value while my code has a field name and "=" in quotes with a reference to a control in the current form.

Duane
Hook'D on Access
MS Access MVP

ojasg (TechnicalUser)
8 Aug 12 14:55
strWhere = "TWONumber =" & Me.TWONumber
DoCmd.OpenForm "frmToolingWorkOrderDuplicate", , , strWhere
DoCmd.Close acForm, "frmCloseToolingWorkOrder"

Yes I had tried this above code. It did not work.
However,

strWhere = "TWONumber =" & Me.TWONumber
DoCmd.Close acForm, "frmCloseToolingWorkOrder"
DoCmd.OpenForm "frmToolingWorkOrderDuplicate", , , strWhere

Works! So changing the order of opening and closing the forms made a difference! Not sure why. But your code now works flawlessely. Thanks a lot for helping out.. I am not reqired to write these databases, but they help me a lot and generous programmers like you always come to my rescue when I am stuck.
Thanks so much .. Cheers!

Also, just out of curiosity. What is difference between -->
TWONumber.Value and "TWONumber =" & Me.TWONumber

Thank You!
dhookom (Programmer)
8 Aug 12 15:48
The ".Value" property is the default property of a bound control so if you don't include, it is assumed.

Duane
Hook'D on Access
MS Access MVP

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close