Need Help Please

T

tmdrake

I have a subform that when you double click on the lastname it brings up
another subform. This works fine, however when I double click on the
lastname a parameter box appears requesting that the lastname is typed in,
then press okay. Below is the code that I am using to accomplish this. How
do I get rid of the parameter box?

Private Sub LastName_DblClick(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String
stLinkCriteria = Me.LastName
stDocName = "frmHours_Worked subform"
DoCmd.OpenForm stDocName, , , "LastName = " & stLinkCriteria

Debug.Print stLinkCriteria

End Sub

Secondly, the subform that appears when you double click on the lastname is
set for datasheet view, however, when it appears it is in single form view.
If you click the design key on the toolbar and then back to the form view it
will appear in datasheet view. How do I fix it so that the subform opens in
datasheet view without have to click design then form?

Please help
 
M

Marshall Barton

tmdrake said:
I have a subform that when you double click on the lastname it brings up
another subform. This works fine, however when I double click on the
lastname a parameter box appears requesting that the lastname is typed in,
then press okay. Below is the code that I am using to accomplish this. How
do I get rid of the parameter box?

Private Sub LastName_DblClick(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String
stLinkCriteria = Me.LastName
stDocName = "frmHours_Worked subform"
DoCmd.OpenForm stDocName, , , "LastName = " & stLinkCriteria

Debug.Print stLinkCriteria

End Sub

Secondly, the subform that appears when you double click on the lastname is
set for datasheet view, however, when it appears it is in single form view.
If you click the design key on the toolbar and then back to the form view it
will appear in datasheet view. How do I fix it so that the subform opens in
datasheet view without have to click design then form?


Because the Last Name field is type Text, you need to make
sure the criteria value is quoted:

DoCmd.OpenForm stDocName, , , _
"LastName = """ & stLinkCriteria & """"

Open the form in design view and set the form's DefaultView
property to DataSheet. Then close and save the form.

Another way is to specify the view on the OpenForm method's
View argument:

DoCmd.OpenForm stDocName, acFormDS, , _
"LastName = """ & stLinkCriteria & """" _
 
T

tmdrake

It worked, Thank You so much!!!!
--
tmdrake


Marshall Barton said:
Because the Last Name field is type Text, you need to make
sure the criteria value is quoted:

DoCmd.OpenForm stDocName, , , _
"LastName = """ & stLinkCriteria & """"

Open the form in design view and set the form's DefaultView
property to DataSheet. Then close and save the form.

Another way is to specify the view on the OpenForm method's
View argument:

DoCmd.OpenForm stDocName, acFormDS, , _
"LastName = """ & stLinkCriteria & """" _
 

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