Getting a form argument

  • Thread starter Thread starter Pete Davis
  • Start date Start date
P

Pete Davis

I have a button on one form at opens another form. I used the wizard and
access created the following code:

Private Sub EditPictures_Click()
On Error GoTo Err_EditPictures_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Picture"

stLinkCriteria = "[PropertyDetailsID]=" & Me![PropertyDetailsID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_EditPictures_Click:
Exit Sub

Err_EditPictures_Click:
MsgBox Err.Description
Resume Exit_EditPictures_Click

End Sub

From the pictures form, in the Form_Load event, I need to get the
PropertyDetailsID and place it in a field. How do I do this?

The Picture form has a PropertyDetailsID field which I assumed would be
auto-populated, but that's not the case.

Thanks, in advance, and really, thanks to everyone who has helped so far.
The people on the Access newsgroups are a terrific help.

Pete
 
You need to place the propertyDetailsId in the OpenArgs
parameter of DoCmd.OpenForm.
Then, in the Load event of the Picture Form, you can access
it by the variable OpenArgs.
You need to remember that the OpenArgs parameter is always
a string so you may have to do some data type conversion.

Hope That Helps
Gerald Stanley MCSD
 
Excellent. That's exactly what I needed to know (specifically, the OpenArgs
parameter in the Form_Load and that it's a string). Thanks a bunch.

Pete

--
http://www.petedavis.net
Gerald Stanley said:
You need to place the propertyDetailsId in the OpenArgs
parameter of DoCmd.OpenForm.
Then, in the Load event of the Picture Form, you can access
it by the variable OpenArgs.
You need to remember that the OpenArgs parameter is always
a string so you may have to do some data type conversion.

Hope That Helps
Gerald Stanley MCSD
-----Original Message-----
I have a button on one form at opens another form. I used the wizard and
access created the following code:

Private Sub EditPictures_Click()
On Error GoTo Err_EditPictures_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Picture"

stLinkCriteria = "[PropertyDetailsID]=" & Me![PropertyDetailsID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_EditPictures_Click:
Exit Sub

Err_EditPictures_Click:
MsgBox Err.Description
Resume Exit_EditPictures_Click

End Sub

From the pictures form, in the Form_Load event, I need to get the
PropertyDetailsID and place it in a field. How do I do this?

The Picture form has a PropertyDetailsID field which I assumed would be
auto-populated, but that's not the case.

Thanks, in advance, and really, thanks to everyone who has helped so far.
The people on the Access newsgroups are a terrific help.

Pete

--
http://www.petedavis.net


.
 
In the Form_Load for the Picture form, I get placed the following:

MsgBox (Me.OpenArgs)

I got an error because Me.OpenArgs is null. The code below in my original
post showed how the Access wizard generated the code for the argument. What
am I missing?

Thanks.

Pete


--
http://www.petedavis.net
Gerald Stanley said:
You need to place the propertyDetailsId in the OpenArgs
parameter of DoCmd.OpenForm.
Then, in the Load event of the Picture Form, you can access
it by the variable OpenArgs.
You need to remember that the OpenArgs parameter is always
a string so you may have to do some data type conversion.

Hope That Helps
Gerald Stanley MCSD
-----Original Message-----
I have a button on one form at opens another form. I used the wizard and
access created the following code:

Private Sub EditPictures_Click()
On Error GoTo Err_EditPictures_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Picture"

stLinkCriteria = "[PropertyDetailsID]=" & Me![PropertyDetailsID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_EditPictures_Click:
Exit Sub

Err_EditPictures_Click:
MsgBox Err.Description
Resume Exit_EditPictures_Click

End Sub

From the pictures form, in the Form_Load event, I need to get the
PropertyDetailsID and place it in a field. How do I do this?

The Picture form has a PropertyDetailsID field which I assumed would be
auto-populated, but that's not the case.

Thanks, in advance, and really, thanks to everyone who has helped so far.
The people on the Access newsgroups are a terrific help.

Pete

--
http://www.petedavis.net


.
 
This is the code to open the form:

stDocName = "Picture"
stLinkCriteria = "[PropertyDetailsID]="Me![PropertyDetailsID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

As I said earlier, this is the code generated by the access wizard. The code
is inside a button _Click event.

No, I actually closed Access and re-opened it, just to be sure, so it wasn't
already open somewhere else.

Pete

Pete
--
http://www.petedavis.net

Gerald Stanley said:
Pete

Some things to check
1. Does the DoCmd.OpenForm statement now look something like
DoCmd.OpenForm stDocName, , , stLinkCriteria, , ,
cstr(Me![PropertyDetailsID])

2. Was the Picture Form already open (maybe in Design
View). When I am passing an argument to a form,I always
trawl through the Forms collection first to check whether
the form is already open and, if so, close it.

Hope That Helps

Gerald Stanley MCSD
-----Original Message-----
In the Form_Load for the Picture form, I get placed the following:

MsgBox (Me.OpenArgs)

I got an error because Me.OpenArgs is null. The code below in my original
post showed how the Access wizard generated the code for the argument. What
am I missing?

Thanks.

Pete


--
http://www.petedavis.net
Gerald Stanley said:
You need to place the propertyDetailsId in the OpenArgs
parameter of DoCmd.OpenForm.
Then, in the Load event of the Picture Form, you can access
it by the variable OpenArgs.
You need to remember that the OpenArgs parameter is always
a string so you may have to do some data type conversion.

Hope That Helps
Gerald Stanley MCSD
-----Original Message-----
I have a button on one form at opens another form. I used
the wizard and
access created the following code:

Private Sub EditPictures_Click()
On Error GoTo Err_EditPictures_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Picture"

stLinkCriteria = "[PropertyDetailsID]=" &
Me![PropertyDetailsID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_EditPictures_Click:
Exit Sub

Err_EditPictures_Click:
MsgBox Err.Description
Resume Exit_EditPictures_Click

End Sub

From the pictures form, in the Form_Load event, I need to
get the
PropertyDetailsID and place it in a field. How do I do this?

The Picture form has a PropertyDetailsID field which I
assumed would be
auto-populated, but that's not the case.

Thanks, in advance, and really, thanks to everyone who has
helped so far.
The people on the Access newsgroups are a terrific help.

Pete

--
http://www.petedavis.net


.


.
 
Pete

Some things to check
1. Does the DoCmd.OpenForm statement now look something like
DoCmd.OpenForm stDocName, , , stLinkCriteria, , ,
cstr(Me![PropertyDetailsID])

2. Was the Picture Form already open (maybe in Design
View). When I am passing an argument to a form,I always
trawl through the Forms collection first to check whether
the form is already open and, if so, close it.

Hope That Helps

Gerald Stanley MCSD
-----Original Message-----
In the Form_Load for the Picture form, I get placed the following:

MsgBox (Me.OpenArgs)

I got an error because Me.OpenArgs is null. The code below in my original
post showed how the Access wizard generated the code for the argument. What
am I missing?

Thanks.

Pete


--
http://www.petedavis.net
Gerald Stanley said:
You need to place the propertyDetailsId in the OpenArgs
parameter of DoCmd.OpenForm.
Then, in the Load event of the Picture Form, you can access
it by the variable OpenArgs.
You need to remember that the OpenArgs parameter is always
a string so you may have to do some data type conversion.

Hope That Helps
Gerald Stanley MCSD
-----Original Message-----
I have a button on one form at opens another form. I used the wizard and
access created the following code:

Private Sub EditPictures_Click()
On Error GoTo Err_EditPictures_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Picture"

stLinkCriteria = "[PropertyDetailsID]=" & Me![PropertyDetailsID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_EditPictures_Click:
Exit Sub

Err_EditPictures_Click:
MsgBox Err.Description
Resume Exit_EditPictures_Click

End Sub

From the pictures form, in the Form_Load event, I need to get the
PropertyDetailsID and place it in a field. How do I do this?

The Picture form has a PropertyDetailsID field which I assumed would be
auto-populated, but that's not the case.

Thanks, in advance, and really, thanks to everyone who has helped so far.
The people on the Access newsgroups are a terrific help.

Pete

--
http://www.petedavis.net


.


.
 
Then you will need to change the DoCmd code to something
along the lines of my previous message as you are not
currently populating the OpenArgs parameter e.g.
DoCmd.OpenForm stDocName, , , stLinkCriteria, , ,
cstr(Me![PropertyDetailsID])

Hope That Helps
Gerald Stanley MCSD
-----Original Message-----
This is the code to open the form:

stDocName = "Picture"
stLinkCriteria = "[PropertyDetailsID]="Me![PropertyDetailsID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

As I said earlier, this is the code generated by the access wizard. The code
is inside a button _Click event.

No, I actually closed Access and re-opened it, just to be sure, so it wasn't
already open somewhere else.

Pete

Pete
--
http://www.petedavis.net

Gerald Stanley said:
Pete

Some things to check
1. Does the DoCmd.OpenForm statement now look something like
DoCmd.OpenForm stDocName, , , stLinkCriteria, , ,
cstr(Me![PropertyDetailsID])

2. Was the Picture Form already open (maybe in Design
View). When I am passing an argument to a form,I always
trawl through the Forms collection first to check whether
the form is already open and, if so, close it.

Hope That Helps

Gerald Stanley MCSD
-----Original Message-----
In the Form_Load for the Picture form, I get placed the following:

MsgBox (Me.OpenArgs)

I got an error because Me.OpenArgs is null. The code below in my original
post showed how the Access wizard generated the code for the argument. What
am I missing?

Thanks.

Pete


--
http://www.petedavis.net
You need to place the propertyDetailsId in the OpenArgs
parameter of DoCmd.OpenForm.
Then, in the Load event of the Picture Form, you can access
it by the variable OpenArgs.
You need to remember that the OpenArgs parameter is always
a string so you may have to do some data type conversion.

Hope That Helps
Gerald Stanley MCSD
-----Original Message-----
I have a button on one form at opens another form. I used
the wizard and
access created the following code:

Private Sub EditPictures_Click()
On Error GoTo Err_EditPictures_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Picture"

stLinkCriteria = "[PropertyDetailsID]=" &
Me![PropertyDetailsID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_EditPictures_Click:
Exit Sub

Err_EditPictures_Click:
MsgBox Err.Description
Resume Exit_EditPictures_Click

End Sub

From the pictures form, in the Form_Load event, I need to
get the
PropertyDetailsID and place it in a field. How do I do this?

The Picture form has a PropertyDetailsID field which I
assumed would be
auto-populated, but that's not the case.

Thanks, in advance, and really, thanks to everyone who has
helped so far.
The people on the Access newsgroups are a terrific help.

Pete

--
http://www.petedavis.net


.



.


.
 
Ah, now I see. Thanks.

Pete

--
http://www.petedavis.net

Gerald Stanley said:
Then you will need to change the DoCmd code to something
along the lines of my previous message as you are not
currently populating the OpenArgs parameter e.g.
DoCmd.OpenForm stDocName, , , stLinkCriteria, , ,
cstr(Me![PropertyDetailsID])

Hope That Helps
Gerald Stanley MCSD
-----Original Message-----
This is the code to open the form:

stDocName = "Picture"
stLinkCriteria = "[PropertyDetailsID]="Me![PropertyDetailsID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

As I said earlier, this is the code generated by the access wizard. The code
is inside a button _Click event.

No, I actually closed Access and re-opened it, just to be sure, so it wasn't
already open somewhere else.

Pete

Pete
--
http://www.petedavis.net

Gerald Stanley said:
Pete

Some things to check
1. Does the DoCmd.OpenForm statement now look something like
DoCmd.OpenForm stDocName, , , stLinkCriteria, , ,
cstr(Me![PropertyDetailsID])

2. Was the Picture Form already open (maybe in Design
View). When I am passing an argument to a form,I always
trawl through the Forms collection first to check whether
the form is already open and, if so, close it.

Hope That Helps

Gerald Stanley MCSD
-----Original Message-----
In the Form_Load for the Picture form, I get placed the
following:

MsgBox (Me.OpenArgs)

I got an error because Me.OpenArgs is null. The code below
in my original
post showed how the Access wizard generated the code for
the argument. What
am I missing?

Thanks.

Pete


--
http://www.petedavis.net
You need to place the propertyDetailsId in the OpenArgs
parameter of DoCmd.OpenForm.
Then, in the Load event of the Picture Form, you can access
it by the variable OpenArgs.
You need to remember that the OpenArgs parameter is always
a string so you may have to do some data type conversion.

Hope That Helps
Gerald Stanley MCSD
-----Original Message-----
I have a button on one form at opens another form. I used
the wizard and
access created the following code:

Private Sub EditPictures_Click()
On Error GoTo Err_EditPictures_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Picture"

stLinkCriteria = "[PropertyDetailsID]=" &
Me![PropertyDetailsID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_EditPictures_Click:
Exit Sub

Err_EditPictures_Click:
MsgBox Err.Description
Resume Exit_EditPictures_Click

End Sub

From the pictures form, in the Form_Load event, I need to
get the
PropertyDetailsID and place it in a field. How do I do
this?

The Picture form has a PropertyDetailsID field which I
assumed would be
auto-populated, but that's not the case.

Thanks, in advance, and really, thanks to everyone who has
helped so far.
The people on the Access newsgroups are a terrific help.

Pete

--
http://www.petedavis.net


.



.


.
 
Back
Top