N
night_writer
Incomplrehensible to me, at least. I'm hoping wiser heads will offer
advice.
I have a form (frmCirculars) that displays individual records of
correspondence (circulars) in single form view. If the form opens
directly, you can cycle through all 13,000 or so records. Each
circular is associated with a project.
I have a project form (frmProjects) that displays all related
circulars in abbreviated fashion on a subform. For any particular
circular on the subform, there is a "view" button that opens a Single
Form view of the associated circular. I would also like to be able to
add a new circular to a project by opening the main circular form in
add mode, and I would like to pass the project number from frmProjects
to the newly opened frmCirculars.
To that end, I have added a button (btnAddNewCircular) to the
frmProjects subform and tried to pass the ProjectID to the new form.
ProjectID is a long integer. Here is my code:
Dim stDocName As String, lngOpenArgs As Long
stDocName = "frmCirculars"
lngOpenArgs = Me.Parent!ProjectID
DoCmd.OpenForm stDocName, , , , acFormAdd, , lngOpenArgs
I've got two problems. The first time I click the button after opening
frmProjects, no opening arguement is passed. I have attached this code
to the Open event of the called form, and I invariably get "OOPS" (no
argument passed) on the first try:
If Not IsNull(Me.OpenArgs) Then
MsgBox "OK"
MsgBox Me.OpenArgs
Me.ProjectID = Me.OpenArgs ' You can't assign a value to this
object
MsgBox Me.ProjectID.Value
Else
MsgBox "OOPS"
End If
If I then close frmCircular and click the button on frmProjects again,
the argument does pass (MsgBox = "OK") and it is the correct argument
(MsgBox Me.OpenArgs).
And here is my second problem. I can't figure out how to get the
opening arguement into the field I want (ProjectID). I get the error
"You can't assign a value to this object." I suppose it's possible
that the Me.ProjectID (which is the same field name in both the
calling and the opening form) might be messing things up, but I have
tried several ways of referencing the field, and nothing seems to
work.
I might also be going about this in the completely wrong way. The
example code in the help file all has to do with finding an existing
record, and all I want to do is put a value in a field of a new
record.
So, these are my two problems:
1. Why won't the OpenArgs pass to the opening form the first time, but
will pass the second time, and
2. How do I need to reference the frmCirculars ProjectID field so it
can be updated with the OpenArgs info
Any help would be greatly appreciated.
advice.
I have a form (frmCirculars) that displays individual records of
correspondence (circulars) in single form view. If the form opens
directly, you can cycle through all 13,000 or so records. Each
circular is associated with a project.
I have a project form (frmProjects) that displays all related
circulars in abbreviated fashion on a subform. For any particular
circular on the subform, there is a "view" button that opens a Single
Form view of the associated circular. I would also like to be able to
add a new circular to a project by opening the main circular form in
add mode, and I would like to pass the project number from frmProjects
to the newly opened frmCirculars.
To that end, I have added a button (btnAddNewCircular) to the
frmProjects subform and tried to pass the ProjectID to the new form.
ProjectID is a long integer. Here is my code:
Dim stDocName As String, lngOpenArgs As Long
stDocName = "frmCirculars"
lngOpenArgs = Me.Parent!ProjectID
DoCmd.OpenForm stDocName, , , , acFormAdd, , lngOpenArgs
I've got two problems. The first time I click the button after opening
frmProjects, no opening arguement is passed. I have attached this code
to the Open event of the called form, and I invariably get "OOPS" (no
argument passed) on the first try:
If Not IsNull(Me.OpenArgs) Then
MsgBox "OK"
MsgBox Me.OpenArgs
Me.ProjectID = Me.OpenArgs ' You can't assign a value to this
object
MsgBox Me.ProjectID.Value
Else
MsgBox "OOPS"
End If
If I then close frmCircular and click the button on frmProjects again,
the argument does pass (MsgBox = "OK") and it is the correct argument
(MsgBox Me.OpenArgs).
And here is my second problem. I can't figure out how to get the
opening arguement into the field I want (ProjectID). I get the error
"You can't assign a value to this object." I suppose it's possible
that the Me.ProjectID (which is the same field name in both the
calling and the opening form) might be messing things up, but I have
tried several ways of referencing the field, and nothing seems to
work.
I might also be going about this in the completely wrong way. The
example code in the help file all has to do with finding an existing
record, and all I want to do is put a value in a field of a new
record.
So, these are my two problems:
1. Why won't the OpenArgs pass to the opening form the first time, but
will pass the second time, and
2. How do I need to reference the frmCirculars ProjectID field so it
can be updated with the OpenArgs info
Any help would be greatly appreciated.