DoCmd OpenForm?

H

Hank

I have a form that is produced from a query. It contains a field called
CustOrderNum. This query produces many records. I want to be able to click
on the correct CustOrderNum using the click event to open another form with
that single record produced. Have tried DoCmd OpenForm and can't get it to
work. Need Help with this one.

Thanks
 
B

Bryan

Hey Hank -

You'll want to use the Where condition of the OpenForm to filter the data to
your selection. Here's an example of what I use when a StuID is clicked:


Private Sub StuID_Click()

Dim stLinkCriteria As String
Dim stDocName As String

stLinkCriteria = "[StuID] = '" & Me.StuID.Value & "'"
stDocName = "WorkEntry"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, "SearchResults"

End Sub

The StuID is a text field so I have to use the single quotes (') around them.
 
H

Hank

Bryan,

Thanks for the code. I inserted it ....Copy follows and when ran I get an
error that the Openform Action was cancelled and to debug. Here is my copy:

Dim stLinkCriteria As String
Dim stDocName As String

stLinkCriteria = "[CustOrderNum] = '" & Me.CustOrderNum.Value & "'"
stDocName = "On Track Logistics Management House Bill"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, "Active Shipments"

Didnt include the Sub Name and End Sub...

Still Stuck..

The 1st query returns results to a form Active Shipments and I want to click
on the Customer Order Number to have it populate the form On Track Logistics
Management House Bill with the correct record.

How can I find the value of the textbox "CustOrderNum" if many records are
returned. This is not datasheet view (by the way) on the form Active Shipments

HELP !!!

Bryan said:
Hey Hank -

You'll want to use the Where condition of the OpenForm to filter the data to
your selection. Here's an example of what I use when a StuID is clicked:


Private Sub StuID_Click()

Dim stLinkCriteria As String
Dim stDocName As String

stLinkCriteria = "[StuID] = '" & Me.StuID.Value & "'"
stDocName = "WorkEntry"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, "SearchResults"

End Sub

The StuID is a text field so I have to use the single quotes (') around them.

Hank said:
I have a form that is produced from a query. It contains a field called
CustOrderNum. This query produces many records. I want to be able to click
on the correct CustOrderNum using the click event to open another form with
that single record produced. Have tried DoCmd OpenForm and can't get it to
work. Need Help with this one.

Thanks
 
H

Hank

Eliminate the single quotes and works like a charm... Thanks Bryan...

Hank said:
Bryan,

Thanks for the code. I inserted it ....Copy follows and when ran I get an
error that the Openform Action was cancelled and to debug. Here is my copy:

Dim stLinkCriteria As String
Dim stDocName As String

stLinkCriteria = "[CustOrderNum] = '" & Me.CustOrderNum.Value & "'"
stDocName = "On Track Logistics Management House Bill"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, "Active Shipments"

Didnt include the Sub Name and End Sub...

Still Stuck..

The 1st query returns results to a form Active Shipments and I want to click
on the Customer Order Number to have it populate the form On Track Logistics
Management House Bill with the correct record.

How can I find the value of the textbox "CustOrderNum" if many records are
returned. This is not datasheet view (by the way) on the form Active Shipments

HELP !!!

Bryan said:
Hey Hank -

You'll want to use the Where condition of the OpenForm to filter the data to
your selection. Here's an example of what I use when a StuID is clicked:


Private Sub StuID_Click()

Dim stLinkCriteria As String
Dim stDocName As String

stLinkCriteria = "[StuID] = '" & Me.StuID.Value & "'"
stDocName = "WorkEntry"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, "SearchResults"

End Sub

The StuID is a text field so I have to use the single quotes (') around them.

Hank said:
I have a form that is produced from a query. It contains a field called
CustOrderNum. This query produces many records. I want to be able to click
on the correct CustOrderNum using the click event to open another form with
that single record produced. Have tried DoCmd OpenForm and can't get it to
work. Need Help with this one.

Thanks
 

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

Similar Threads


Top