Opening a form to display specific information

M

MEAD5432

I have a database to track workorders and a form with a drop down menu to
sort by employee name in a subform.

The workorder ID is set so that a user can double click the workorder number
and it opens up the workorder form. The problem is, I don't know how to get
it to open to the specific workorder number. Instead, it opens all
workorders.

Here is the coding I have set up for the double click event:

Private Sub Workorder_ID_DblClick(Cancel As Integer)
On Error GoTo Err_Workorder_ID_DblClick

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Workorder Form"
DoCmd.OpenForm stDocName, , , stLinkCriteria


Exit_Workorder_ID_DblClick:
Exit Sub

Err_Workorder_ID_DblClick:
MsgBox Err.Description
Resume Exit_Workorder_ID_DblClick

End Sub


I am a novice at VBA so I am probably just missing something really easy.
Any suggestions?

I am building the DB in Office 2003 on XP Pro. All programs are fully
updated.
 
M

Maverick

You don't have any criteria set to choose the workorder. The stLinkCriteria
needs to have a value in order to do what you want. Try adding the following
code Where [ID] is the name of the control on the workorder form you are
opening ( make sure you have the [] around the control name as you see below:

stLinkCriteria = "[ID]=" & Me.Workorder_ID


HTH
 
M

MEAD5432

Thanks for the reply. I changed the code to add your suggestion but now
when I double clikc on the workorder, it opens the form in add mode.

Is this just a case of Access not reading the identifier from the first form
to input into the second?

I forgot to mention that the workorder numbers are "W000X" rather than
simply "1", "2", etc... I don't know if that ill have an effect since it is
an input mask and the actual ID is only 1, 2, etc... This formatting can be
easily changed if necessary.

Thanks,

-B

Maverick said:
You don't have any criteria set to choose the workorder. The stLinkCriteria
needs to have a value in order to do what you want. Try adding the following
code Where [ID] is the name of the control on the workorder form you are
opening ( make sure you have the [] around the control name as you see below:

stLinkCriteria = "[ID]=" & Me.Workorder_ID


HTH

MEAD5432 said:
I have a database to track workorders and a form with a drop down menu to
sort by employee name in a subform.

The workorder ID is set so that a user can double click the workorder number
and it opens up the workorder form. The problem is, I don't know how to get
it to open to the specific workorder number. Instead, it opens all
workorders.

Here is the coding I have set up for the double click event:

Private Sub Workorder_ID_DblClick(Cancel As Integer)
On Error GoTo Err_Workorder_ID_DblClick

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Workorder Form"
DoCmd.OpenForm stDocName, , , stLinkCriteria


Exit_Workorder_ID_DblClick:
Exit Sub

Err_Workorder_ID_DblClick:
MsgBox Err.Description
Resume Exit_Workorder_ID_DblClick

End Sub


I am a novice at VBA so I am probably just missing something really easy.
Any suggestions?

I am building the DB in Office 2003 on XP Pro. All programs are fully
updated.
 
M

Maverick

You can change the mode in which you wish to have the form open. The options
are: acFormAdd, acFormEdit, acFormProperty, and acFormReadOnly. The syntax
is as follows (with DataMode where you would choose the mode in which the
form opens):

DoCmd.OpenForm(FormName, View, FilterName, WhereCondition, DataMode,
WindowMode, OpenArgs)

Your code would look something like this if you wanted it to open in edit
mode:

DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormEdit


MEAD5432 said:
Thanks for the reply. I changed the code to add your suggestion but now
when I double clikc on the workorder, it opens the form in add mode.

Is this just a case of Access not reading the identifier from the first form
to input into the second?

I forgot to mention that the workorder numbers are "W000X" rather than
simply "1", "2", etc... I don't know if that ill have an effect since it is
an input mask and the actual ID is only 1, 2, etc... This formatting can be
easily changed if necessary.

Thanks,

-B

Maverick said:
You don't have any criteria set to choose the workorder. The stLinkCriteria
needs to have a value in order to do what you want. Try adding the following
code Where [ID] is the name of the control on the workorder form you are
opening ( make sure you have the [] around the control name as you see below:

stLinkCriteria = "[ID]=" & Me.Workorder_ID


HTH

MEAD5432 said:
I have a database to track workorders and a form with a drop down menu to
sort by employee name in a subform.

The workorder ID is set so that a user can double click the workorder number
and it opens up the workorder form. The problem is, I don't know how to get
it to open to the specific workorder number. Instead, it opens all
workorders.

Here is the coding I have set up for the double click event:

Private Sub Workorder_ID_DblClick(Cancel As Integer)
On Error GoTo Err_Workorder_ID_DblClick

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Workorder Form"
DoCmd.OpenForm stDocName, , , stLinkCriteria


Exit_Workorder_ID_DblClick:
Exit Sub

Err_Workorder_ID_DblClick:
MsgBox Err.Description
Resume Exit_Workorder_ID_DblClick

End Sub


I am a novice at VBA so I am probably just missing something really easy.
Any suggestions?

I am building the DB in Office 2003 on XP Pro. All programs are fully
updated.
 
M

MEAD5432

I figured it out. I wasn't putting the stLinkCriteria as a string above, I
was putting it into the command...

I really appreciate the help. Thanks!


Maverick said:
You can change the mode in which you wish to have the form open. The options
are: acFormAdd, acFormEdit, acFormProperty, and acFormReadOnly. The syntax
is as follows (with DataMode where you would choose the mode in which the
form opens):

DoCmd.OpenForm(FormName, View, FilterName, WhereCondition, DataMode,
WindowMode, OpenArgs)

Your code would look something like this if you wanted it to open in edit
mode:

DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormEdit


MEAD5432 said:
Thanks for the reply. I changed the code to add your suggestion but now
when I double clikc on the workorder, it opens the form in add mode.

Is this just a case of Access not reading the identifier from the first form
to input into the second?

I forgot to mention that the workorder numbers are "W000X" rather than
simply "1", "2", etc... I don't know if that ill have an effect since it is
an input mask and the actual ID is only 1, 2, etc... This formatting can be
easily changed if necessary.

Thanks,

-B

Maverick said:
You don't have any criteria set to choose the workorder. The stLinkCriteria
needs to have a value in order to do what you want. Try adding the following
code Where [ID] is the name of the control on the workorder form you are
opening ( make sure you have the [] around the control name as you see below:

stLinkCriteria = "[ID]=" & Me.Workorder_ID


HTH

:

I have a database to track workorders and a form with a drop down menu to
sort by employee name in a subform.

The workorder ID is set so that a user can double click the workorder number
and it opens up the workorder form. The problem is, I don't know how to get
it to open to the specific workorder number. Instead, it opens all
workorders.

Here is the coding I have set up for the double click event:

Private Sub Workorder_ID_DblClick(Cancel As Integer)
On Error GoTo Err_Workorder_ID_DblClick

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Workorder Form"
DoCmd.OpenForm stDocName, , , stLinkCriteria


Exit_Workorder_ID_DblClick:
Exit Sub

Err_Workorder_ID_DblClick:
MsgBox Err.Description
Resume Exit_Workorder_ID_DblClick

End Sub


I am a novice at VBA so I am probably just missing something really easy.
Any suggestions?

I am building the DB in Office 2003 on XP Pro. All programs are fully
updated.
 
M

Maverick

HTH

MEAD5432 said:
I figured it out. I wasn't putting the stLinkCriteria as a string above, I
was putting it into the command...

I really appreciate the help. Thanks!


Maverick said:
You can change the mode in which you wish to have the form open. The options
are: acFormAdd, acFormEdit, acFormProperty, and acFormReadOnly. The syntax
is as follows (with DataMode where you would choose the mode in which the
form opens):

DoCmd.OpenForm(FormName, View, FilterName, WhereCondition, DataMode,
WindowMode, OpenArgs)

Your code would look something like this if you wanted it to open in edit
mode:

DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormEdit


MEAD5432 said:
Thanks for the reply. I changed the code to add your suggestion but now
when I double clikc on the workorder, it opens the form in add mode.

Is this just a case of Access not reading the identifier from the first form
to input into the second?

I forgot to mention that the workorder numbers are "W000X" rather than
simply "1", "2", etc... I don't know if that ill have an effect since it is
an input mask and the actual ID is only 1, 2, etc... This formatting can be
easily changed if necessary.

Thanks,

-B

:

You don't have any criteria set to choose the workorder. The stLinkCriteria
needs to have a value in order to do what you want. Try adding the following
code Where [ID] is the name of the control on the workorder form you are
opening ( make sure you have the [] around the control name as you see below:

stLinkCriteria = "[ID]=" & Me.Workorder_ID


HTH

:

I have a database to track workorders and a form with a drop down menu to
sort by employee name in a subform.

The workorder ID is set so that a user can double click the workorder number
and it opens up the workorder form. The problem is, I don't know how to get
it to open to the specific workorder number. Instead, it opens all
workorders.

Here is the coding I have set up for the double click event:

Private Sub Workorder_ID_DblClick(Cancel As Integer)
On Error GoTo Err_Workorder_ID_DblClick

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Workorder Form"
DoCmd.OpenForm stDocName, , , stLinkCriteria


Exit_Workorder_ID_DblClick:
Exit Sub

Err_Workorder_ID_DblClick:
MsgBox Err.Description
Resume Exit_Workorder_ID_DblClick

End Sub


I am a novice at VBA so I am probably just missing something really easy.
Any suggestions?

I am building the DB in Office 2003 on XP Pro. All programs are fully
updated.
 

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