Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pop-up form field value completed based on pop-up criteria

Status
Not open for further replies.

cdck

Programmer
Nov 25, 2003
281
US
I have a pop-up form which shows records from a secondary table associated with the record selected on a main form. The pop-up opens with the following code on a command button:
[tt]
Private Sub cmdFailCodes_Click()
On Error GoTo Err_cmdFailCodes_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Failure Codes"

stLinkCriteria = "[QAinProcInspTimesID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdFailCodes_Click:
Exit Sub

Err_cmdFailCodes_Click:
MsgBox Err.Description
Resume Exit_cmdFailCodes_Click

End Sub
[/tt]
The form shows up in continuous forms view, and users can add new records.

The problem is how to have the QAinProcInspTimesID for new records fill in with the default value of Me![ID] that was used to open the form - now that we're on a different form and Me![ID] has been left behind. I would have it reference an existing record pulled by the pop-up, but usually there won't be any records pulled when the form first opens, because they won't yet exist.

Cheryl dc Kern
 
Here's a few things you could try...

If the old form is still left open after you load the new form you could use a textbox on the old form and reference it in the on load event of the new form.

or

Not sure if this will work, but take a look at the openargs method.

or

dimension a global variable and pass the ID value to that.

or

I'm assuming that you are using or have a fild called QAinProcInspTimesID in your new form? that will have the value of id in it I presume



Ian Mayor (UK)
Program Error
Always make your words sweet and nice. Because you never know when you may have to eat them.
 
Yes, I have QAinProcInspTimesID on the new form, but it will only have that value in it if any records are pulled from the database because that field matches. I need my users to be able to add new records and have that field fill in even when no records were pulled.

I'm looking into the global variable now, thank you very much for giving me a path to follow. It's amazing how much information you can find when you know some proper terms to search for. I'll get back to you with my results. I'm going to try referencing the field on the old form to set the variable as the new form opens...



Cheryl dc Kern
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top