Auto Fill-in Field on Second Form

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
 
G

Guest

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
 
G

Guest

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
 
G

Guest

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
 

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