Solved OpenArgs populate textbox (1 Viewer)

Mario R. Perez

New member
Local time
Today, 13:57
Joined
May 14, 2020
Messages
12
Hi there, I'm obviously doing something wrong, but can't figure out what it is, and this should be pretty simple.

I have a button on a form(form1) that opens another form(form2) and not populates a textboxes in the second form with a the values from openargs.

form1
Private Sub Command31_Click()

DoCmd.OpenForm "form2", , , , , , "select ID,Fldsize from TBLSIZE"

end sub

form2 (default view: Continuous Forms, 2 unbound Textboxes : TextId,TextSize)

Private Sub Form_Open(Cancel As Integer)
If Not IsNull(Me.OpenArgs) Then
Me.RecordSource = Me.OpenArgs
Me.TextId = Me!ID 'not populate only first rec
Me.TextSize = Me!Fldsize 'not populate only first rec
End If

end sub

Thanks for advance
 

Gasman

Enthusiastic Amateur
Local time
Today, 18:57
Joined
Sep 21, 2011
Messages
14,310
Have you done the simple stuff, like walking your code and inspecting values?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:57
Joined
Oct 29, 2018
Messages
21,474
Rather than these:
Code:
Me.TextId = Me!ID 'not populate only first rec
Me.TextSize = Me!Fldsize 'not populate only first rec
Perhaps you meant these?
Code:
Me.TextId.ControlSource = ID
Me.TextSize.ControlSource = Fldsize
 

Gasman

Enthusiastic Amateur
Local time
Today, 18:57
Joined
Sep 21, 2011
Messages
14,310
I tested the O/P's code with my fields and it worked for me?, so not sure what else is going on? I made my controls unbound which is what they have appeared to do?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:57
Joined
Oct 29, 2018
Messages
21,474
I tested the O/P's code with my fields and it worked for me?, so not sure what else is going on? I made my controls unbound which is what they have appeared to do?
Did you also try to use a Continuous Form as the OP did?
 

Gasman

Enthusiastic Amateur
Local time
Today, 18:57
Joined
Sep 21, 2011
Messages
14,310
No sorry, just a form I had from another site.
 

Gasman

Enthusiastic Amateur
Local time
Today, 18:57
Joined
Sep 21, 2011
Messages
14,310
Ah I see, I misunderstood his issue. :(
I have just done that with a Continuous form and I see what you mean, as control is unbound, all are set to whatever the values are.

My apologies @theDBguy and O/P. :(
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:57
Joined
Oct 29, 2018
Messages
21,474
Ah I see, I misunderstood his issue. :(
I have just done that with a Continuous form and I see what you mean, as control is unbound, all are set to whatever the values are.

My apologies @theDBguy and O/P. :(
No worries. 👍
 

Mario R. Perez

New member
Local time
Today, 13:57
Joined
May 14, 2020
Messages
12
Rather than these:
Code:
Me.TextId = Me!ID 'not populate only first rec
Me.TextSize = Me!Fldsize 'not populate only first rec
Perhaps you meant these?
Code:
Me.TextId.ControlSource = ID
Me.TextSize.ControlSource = Fldsize
I tried as you indicated, but it does not recognize the "ID" field, it takes it as a non-existent variable
 

Attachments

  • Screenshot 2023-08-12 214006.png
    Screenshot 2023-08-12 214006.png
    23.6 KB · Views: 54

MajP

You've got your good things, and you've got mine.
Local time
Today, 13:57
Joined
May 21, 2018
Messages
8,529
Me.TextId.ControlSource = ID
Me.TextSize.ControlSource = Fldsize
I think the @theDBguy made a typo, because that would assume variables. These properties are strings.
Code:
Me.TextId.ControlSource = "ID"
Me.TextSize.ControlSource = "Fldsize"
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:57
Joined
Oct 29, 2018
Messages
21,474
I think the @theDBguy made a typo, because that would assume variables. These properties are strings.
Code:
Me.TextId.ControlSource = "ID"
Me.TextSize.ControlSource = "Fldsize"
Oops, my bad. Thanks for the assist @MajP!
 

Mario R. Perez

New member
Local time
Today, 13:57
Joined
May 14, 2020
Messages
12
I think the @theDBguy made a typo, because that would assume variables. These properties are strings.
Code:
Me.TextId.ControlSource = "ID"
Me.TextSize.ControlSource = "Fldsize"
Now it works, thank you very much MajP and everyone who read my post.
 

Users who are viewing this thread

Top Bottom