Unable to open form from another form

A

Amit

Hi,

I have a form with a list of names and StaffID in
datasheet view. In the DoubleClick event of the name, I
have the following code:
Private Sub Staff_Name_DblClick(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmStaff"
DoCmd.OpenForm stDocName, , , , acFormEdit, , Me!
[StaffID]
End Sub

I'm trying to open another form (frmStaff) when the name
is double-clicked. In the FormLoad event of the
form 'frmStaff', I have the following code:
Private Sub Form_Load()
If (OpenArgs <> "") Then
StaffID = OpenArgs
End If
End Sub

This is not working. When I double-click the name, I get
the following error: "You can't assign a value to this
object.".
When I Debug the code for 'frmStaff', I see different
values for "StaffID" and "OpenArgs".

Not sure how to correct this, and will appreciate any help.

Thanks!

-Amit
 
G

Gary Miller

Amit,

I can see a couple of problems here, one of which is that in
the Load event you are not really telling it to go to a
record.

If what you are doing is trying to open the form to a
certain record, try this simpler method using the Where
clause of the OpenForm method...

Private Sub Staff_Name_DblClick(Cancel As Integer)

Dim stDocName As String
Dim stLinkCriteria As String
Dim stWhere as String

stDocName = "frmStaff"
stWhere = "[StaffID] = " & Me![StaffID] 'ADDED

DoCmd.OpenForm stDocName, , , stWhere, acFormEdit

End Sub

Gary Miller
 
A

Amit

Hi Gary,

Thanks for your reply. I'd figured out part of the
problem, and your response made it all clear. Thanks again.

-Amit

-----Original Message-----
Amit,

I can see a couple of problems here, one of which is that in
the Load event you are not really telling it to go to a
record.

If what you are doing is trying to open the form to a
certain record, try this simpler method using the Where
clause of the OpenForm method...

Private Sub Staff_Name_DblClick(Cancel As Integer)

Dim stDocName As String
Dim stLinkCriteria As String
Dim stWhere as String

stDocName = "frmStaff"
stWhere = "[StaffID] = " & Me![StaffID] 'ADDED

DoCmd.OpenForm stDocName, , , stWhere, acFormEdit

End Sub

Gary Miller

Amit said:
Hi,

I have a form with a list of names and StaffID in
datasheet view. In the DoubleClick event of the name, I
have the following code:
Private Sub Staff_Name_DblClick(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmStaff"
DoCmd.OpenForm stDocName, , , , acFormEdit, , Me!
[StaffID]
End Sub

I'm trying to open another form (frmStaff) when the name
is double-clicked. In the FormLoad event of the
form 'frmStaff', I have the following code:
Private Sub Form_Load()
If (OpenArgs <> "") Then
StaffID = OpenArgs
End If
End Sub

This is not working. When I double-click the name, I get
the following error: "You can't assign a value to this
object.".
When I Debug the code for 'frmStaff', I see different
values for "StaffID" and "OpenArgs".

Not sure how to correct this, and will appreciate any help.

Thanks!

-Amit


.
 

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