Open Args Question

B

Biggles

I know this should be easy, and I might have examples somewhere myself.
However, it is late (after golf even) and I want to go to bed and have the
Magic MVP Pixies out there answer my question while I sleep.

I have a subform with a value, and I want to pass that value onto a form to
be opened. Here is the code for the button:

Private Sub Command24_Click()
On Error GoTo Err_Command24_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim stARGS As String

stARGS = Me!frmPROJECTENTRY!txtPROJECTID
stDocName = "sfrmproj_budgeting"
DoCmd.OpenForm stDocName, , , , , , stARGS

Exit_Command24_Click:
Exit Sub

Err_Command24_Click:
MsgBox Err.Description
Resume Exit_Command24_Click

Okey? Then, how do I make the field in the form that I am opening use the
openargs (assuming that part is correct).

I have set the Form On Open event to ME.TXTPROJECTID = ME.OPENARGS and was
told I cannot assign the value of that object.

I have set the default value to me.openargs, me!openargs. I throw up my
arms in exasperation (and forget how to spell when frustrated) and beg for
help.

Help!
 
O

Ofer

The ME.TXTPROJECTID = ME.OPENARGS should do the trick, you might have a
problem updating the TXTPROJECTID field, try to enter value in to it.
If the ControlSource Property of the field bounded to a calculate field like
=dlookup, =dsum, then you wont be able to insert value in to it.
Also if the field in the form bounded to a field in the table that the form
is bounded to the try and run the sql of the record source separately and see
if you can update values in it.
 
D

Dirk Goldgar

Ofer said:
The ME.TXTPROJECTID = ME.OPENARGS should do the trick, you might
have a problem updating the TXTPROJECTID field, try to enter value in
to it.
If the ControlSource Property of the field bounded to a calculate
field like =dlookup, =dsum, then you wont be able to insert value in
to it.
Also if the field in the form bounded to a field in the table that
the form is bounded to the try and run the sql of the record source
separately and see if you can update values in it.

In addition to these ideas, the problem may be that the form's Open
event is too soon to be assigning a value to a bound control, since the
form's recordset hasn't been loaded yet. Biggles, try moving the code
to the form's Load event or (if it makes sense to do so) the Current
event.
 
B

Biggles

Thank you both very much -

Ofer - I was able to edit the field, but I am sure another (less critical)
error is because of that very situation.

Dirk - That worked, the on open must have been too early. I am glad it
wasn't super easy, even though it was simple.

Biggles
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top