Auto Fill-in Field on Second Form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I'm hoping someone can help me with opening a second form and have a field
automatically fill in from first form. Ex: First form "fQuote" with combo
"PartIDNumber". Second Form "fPartsList" with field "PartIDNumber".

If user types in a part number in combo and it isn't in list, I want the
form Parts List to open, but have the part number automatically filled in so
user won't have to retype the same info.

I've read a couple of posts and entered some code (some with OpenArgs -
don't really understand), but nothing will work.

Any help is appreciated! Thanks in advance!!
Pam
 
As you said, use the OpenArgs in the open form command line

docmd.OpenForm "fPartsList",,,,,,Me.PartIDNumber

On the OnLoad event of the second form you can use it
Me.PartIDNumber = Me.OpenArgs
 
Ofer,

Thank you for replying so quickly. I tried to use the code you gave, but
received error message "An expression you entered is the wrong data type for
one of the arguments."

If you don't mind, would you please take a look at the code I'm using and
tell me what I'm doing wrong.

This is from form "fPkgQuotePartsList"
Private Sub CboPartIDNumber_NotInList(NewData As String, Response As Integer)
On Error GoTo Err_CboPartIDNumber_NotInList

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "fPkgMiscPartsList"
DoCmd.OpenForm stDocName, , , , , , Me.PartIDNumber
Response = acDataErrAdded

Exit_CboPartIDNumber_NotInList:
Exit Sub

Err_CboPartIDNumber_NotInList:
MsgBox Err.Description
Resume Exit_CboPartIDNumber_NotInList
End Sub

and this is from "fPkgMiscPartsList"

Private Sub Form_Load()
Me.PartIDNumber = Me.OpenArgs
End Sub

I've spent a considerable amount of time trying to work this out, so any
help is greatly appreciated!

Thanks,
Pam
 
Try this

Private Sub CboPartIDNumber_NotInList(NewData As String, Response As Integer)
On Error GoTo Err_CboPartIDNumber_NotInList

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "fPkgMiscPartsList"
DoCmd.OpenForm stDocName, , , , ,acDialog , NewData

Response = acDataErrAdded

Exit_CboPartIDNumber_NotInList:
Exit Sub

Err_CboPartIDNumber_NotInList:
MsgBox Err.Description
Resume Exit_CboPartIDNumber_NotInList
End Sub
 
Back
Top