Opening Arguments

R

Ripper

I tried to create this without help, but I cannot figure out why it won't work.

I have a button on a subform whose control and name are dhallID. In the
OnClick event I placed the following code:
DoCmd.OpenForm "frmDhallAddDisc", , , , , , "[DHallID] =" & Me.[DHallID]

I want it to open the form to the specific record in the OpenArguments. The
Dhall ID is the primary key for the table that this form opens from and it is
also an autonumber field.

I cannot figure it out and would appreciate some help.
 
A

Albert D. Kallal

I tried to create this without help, but I cannot figure out why it won't
work.

I have a button on a subform whose control and name are dhallID. In the
OnClick event I placed the following code:
DoCmd.OpenForm "frmDhallAddDisc", , , , , , "[DHallID] =" & Me.[DHallID]

I want it to open the form to the specific record in the OpenArguments.
The
Dhall ID is the primary key for the table that this form opens from and it
is
also an autonumber field.

I cannot figure it out and would appreciate some help.


you have a few too many comma in your syntax

You should have as you type see the parameters (inteli-sense) showing you
what each parameter is for as you type a comma. This really helps a lot
during code entry. (If the Inteli-sense stopped working for you this often
means that you have other compile errors in your code, I would do a debug
compile and make sure that you removed any syntax errors from your code
project as a whole).


anyway try the following


DoCmd.OpenForm "frmDhallAddDisc",,, "[DHallID] =" & Me.[DHallID]

also if that field is a text based field, then you have to surround the
actual data which quotes thus you'll need

DoCmd.OpenForm "frmDhallAddDisc",,, "[DHallID] ='" & Me.[DHallID] & "'"

in the above I've actually used single quotes (they work also ).

in addition if the form your currently on allows any editing of data then
you need to force a disk right before firing up and loading another form
that's going to be pointing to same record (if you don't do this you'll get
that nasty error message about how this record been modified by another
user, in actual fact that other user is your other form).

So if the first form or regional form allows editing of the data, then make
sure you flush are forced to describe to disk:

use the following

if me.Dirty = true then
me.Dirty = false
end if
DoCmd.OpenForm "frmDhallAddDisc",,, "[DHallID] =" & Me.[DHallID]
 
S

Stuart McCall

Ripper said:
I tried to create this without help, but I cannot figure out why it won't
work.

I have a button on a subform whose control and name are dhallID. In the
OnClick event I placed the following code:
DoCmd.OpenForm "frmDhallAddDisc", , , , , , "[DHallID] =" & Me.[DHallID]

I want it to open the form to the specific record in the OpenArguments.
The
Dhall ID is the primary key for the table that this form opens from and it
is
also an autonumber field.

I cannot figure it out and would appreciate some help.

You are passing a WhereCondition argument in the OpenArgs parameter. Change
the line to look like this:

DoCmd.OpenForm "frmDhallAddDisc" , , , "[DHallID] =" & Me.[DHallID]

or better still (for readability) use a named argument:

DoCmd.OpenForm "frmDhallAddDisc", WhereCondition:="[DHallID] =" &
Me.[DHallID]
 
S

Stuart McCall

Ripper said:
I tried to create this without help, but I cannot figure out why it won't
work.

I have a button on a subform whose control and name are dhallID. In the
OnClick event I placed the following code:
DoCmd.OpenForm "frmDhallAddDisc", , , , , , "[DHallID] =" & Me.[DHallID]

I want it to open the form to the specific record in the OpenArguments.
The
Dhall ID is the primary key for the table that this form opens from and it
is
also an autonumber field.

I cannot figure it out and would appreciate some help.

I posted a nice concise answer to your question, but it was removed from the
server. I can only conclude this was malicious behaviour by someone with an
axe to grind.

So here goes again:

You are passing a WhereCondition argument in the OpenArgs parameter. Change
the line to look like this:

DoCmd.OpenForm "frmDhallAddDisc" , , , "[DHallID] =" & Me.[DHallID]

or better still (for readability) use a named argument:

DoCmd.OpenForm "frmDhallAddDisc", WhereCondition:="[DHallID] =" &
Me.[DHallID]
 

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