By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,456 Members | 1,400 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,456 IT Pros & Developers. It's quick & easy.

NewData and OpenArgs to pass values from form to form...problems

P: n/a
I have a form (frmWorksheet) that contains project information from a
Projects table. The form contains a number of fields including ClientID and
Project. On the form header is two combo boxes, SelectClient and
SelectProject. When a user selects a client from the SelectClient combo,
only the projects associated with that client will appear in the
SelectProjects combo.

If the user wants to add a new project to that list, they can dblclick the
field to open an entry form (frmNewProject).

My problem is this. When the user dblclicks the field, I want to open the
frmNewProject form AND pass the client from SelectClient in the first combo
box to the frmNewProject form and put it into the ClientID control. I am
attempting to do this using NewData and OpenArgs but have been unsuccessful
to this point.

In the DblClick event for the SelectProject combo I have the following:

Private Sub SelectProject_DblClick(Cancel As Integer)
On Error GoTo Err_SelectProject_DblClick
Dim stDocName As String
Dim NewData As String ', Response As Integer

stDocName = "frmNewProject"
DoCmd.OpenForm stDocName, acNormal, , , acFormAdd, acDialog, NewData
Exit_SelectProject_DblClick:
Exit Sub
Err_SelectProject_DblClick:
MsgBox Err.Description
Resume Exit_SelectProject_DblClick
End Sub

In the OnLoad event for the frmNewPoject I have:

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

When I use this code, I don't get any errors, however, nothing gets passed
to frmNewProject. I have tried other variations, all of which resulted in
various errors.

I am not very experienced with vb coding, but after studying the code, I am
begining to think that my problem may be that there is not NewData to be
passed to frmNewProject. From reading old posts in the archives, it seems
that NewData is generally used with the NotInList event, where a user would
have typed in some data, ie New Data, whereas in my case I have not given
any new data. Is this an accurate representation of my troubles? If so,
where should I begin in trying to fix the problem? Any suggestions greatly
appreciated.
May 15 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
dim lngClientID as Long

lngClientID = me.ClientID
DoCmd.OpenForm stDocName, acNormal, , , acFormAdd, acDialog, lngClientID

John

"Robert" <no**@email.com> wrote in message
news:t7*******************@fe01.news.easynews.com. ..
I have a form (frmWorksheet) that contains project information from a
Projects table. The form contains a number of fields including ClientID and Project. On the form header is two combo boxes, SelectClient and
SelectProject. When a user selects a client from the SelectClient combo,
only the projects associated with that client will appear in the
SelectProjects combo.

If the user wants to add a new project to that list, they can dblclick the
field to open an entry form (frmNewProject).

My problem is this. When the user dblclicks the field, I want to open the
frmNewProject form AND pass the client from SelectClient in the first combo box to the frmNewProject form and put it into the ClientID control. I am
attempting to do this using NewData and OpenArgs but have been unsuccessful to this point.

In the DblClick event for the SelectProject combo I have the following:

Private Sub SelectProject_DblClick(Cancel As Integer)
On Error GoTo Err_SelectProject_DblClick
Dim stDocName As String
Dim NewData As String ', Response As Integer

stDocName = "frmNewProject"
DoCmd.OpenForm stDocName, acNormal, , , acFormAdd, acDialog, NewData
Exit_SelectProject_DblClick:
Exit Sub
Err_SelectProject_DblClick:
MsgBox Err.Description
Resume Exit_SelectProject_DblClick
End Sub

In the OnLoad event for the frmNewPoject I have:

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

When I use this code, I don't get any errors, however, nothing gets passed
to frmNewProject. I have tried other variations, all of which resulted in
various errors.

I am not very experienced with vb coding, but after studying the code, I am begining to think that my problem may be that there is not NewData to be
passed to frmNewProject. From reading old posts in the archives, it seems
that NewData is generally used with the NotInList event, where a user would have typed in some data, ie New Data, whereas in my case I have not given
any new data. Is this an accurate representation of my troubles? If so,
where should I begin in trying to fix the problem? Any suggestions greatly
appreciated.

May 15 '06 #2

P: n/a
you should use OpenArgs. That works fine if you only need to send one
id, if you need to send more information you can still use OpenArgs
concatenating the values you want and making a function that get the
value like an array

Dim stDocName As String
Dim stLinkCriteria As String
Dim stOpenArgs As String

stDocName = "yourForm"
stOpenArgs = valueToPass
stLinkCriteria = "[id]=" & Me![id]

DoCmd.OpenForm stDocName, , , stLinkCriteria, , , stOpenArgs

yourForm

on Form_Open
field = Me.OpenArgs

May 15 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.