Popup form

W

Wayne Livingstone

Let me see if I can explain what I'm trying to do:

I have a sub-form that displays as a continuous form so
that I can see all the relevant records in a list format.
On the sub-form I have a "Select" button which opens a new
form. A Select button appears in each record displayed in
the sub-form. The ID field for the sub-form data is
PrintReqSubID from the PrintReq_Sub table.
The form I want to open is PlotSelect and its recordsource
is also the PrintReq_Sub table. I want the PlotSelect form
to open at the same PrintReqSubID as the one where I
clicked the Select button.
I have tried the following code and a few variations but
the PlotSelect form always opens at a new record.

Private Sub Select_Click()

On Error GoTo Err_Select_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "PlotSelect"

If IsNull([PrintSubID]) Then
MsgBox "You must start a new record."
DoCmd.GoToControl "Date"
Else
stLinkCriteria = "[PrintReq_Sub].[PrintSubID]=" &
Forms![PrintRequisition]![PrintReq_Subform]![PrintSubID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
' Me.Visible = False
End If

Exit_Select_Click:
Exit Sub

Err_Select_Click:
MsgBox Err.Description
Resume Exit_Select_Click

End Sub
 
A

Albert D. Kallal

The strLinkcriteia is supposed to be a correctly formed sql "where" clause
without the word where...

so:
stLinkCriteria = "PrintSubID = " & me.PrintSubID
DoCmd.OpenForm stDocName, , , stLinkCriteria


The above should do the trick...

Note how PrntSubID is just simply a value from the table in the forms
recordset (that we are about to open).
 
W

Wayne Livingstone

Thanks for that, but the PlotSelect form still only opens
at a new record. Could I have a property set on the form
itself that tells it to only open a new record?
I tried opening the PlotSelect form manually and it still
only opens at a new record and no ability to navigate
through other records. And there are definately other
records in the table.

Any ideas?
 
A

Albert D. Kallal

Thanks for that, but the PlotSelect form still only opens
at a new record. Could I have a property set on the form
itself that tells it to only open a new record?

Yes, check if you have the "data entry" property set to "yes" for the form
(this setting means the form is ONLY for data entry..and not editing of
data).
 

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