Pat,
I suspect this has to do with the fact that the line of code:
DoCmd.Close acForm, strName
in Sub OpenNextForm closes the previous form as soon as the next one is
opened, so when your code in Sub SetAutoValues looks for form
fScrEligCriteria, that one is already closed (assuming the hardcoded
form name is correct, and the control names are the same on all forms!).
Since the four controls' data is to be carried along unchanged
throughout the four forms, I would do what you are after from within Sub
OpenNextForm, by reading the controls' values from the previous form
just before closing it (as opposed to try to read from the first one in
the series). To achieve this, I would modify the code as follows (watch
out for wrapping):
Sub OpenNextForm(strName As String)
Dim intOrder As Integer, frmName As String
On Error GoTo OpenNextForm_Err
intOrder = DLookup("[FormOrder]", "LU_Forms", "[FormName]= '" &
strName & "'")
frmName = DLookup("[FormName]", "LU_Forms", "[FormOrder]= " &
intOrder + 1)
If Not IsNull(frmName) Then
DoCmd.OpenForm frmName, , , , acAdd
End If
'new section
Me.studyday = Forms(strName).studyday
Me.patient = Forms(strName).patient
Me.pat_init = Forms(strName).pat_init
Me.site = Forms(strName).site
'end of new section
DoCmd.Close acForm, strName
OpenNextForm_Err:
'MsgBox Err.Description
Resume Next
End Sub
HTH,
Nikos
> Hello,
>
[quoted text clipped - 60 lines]
> the 4 header fields by clicking on the Command Button would be greatly
> appreciated.
Pat Dools - 11 Jan 2005 00:37 GMT
Hi Nikos (and all),
Inserting the code as noted below, I keep getting the error message,
'Invalid use of Me keyword'. Doesn't 'Me' just mean the active form?
Thanks, Patrick
> Pat,
>
[quoted text clipped - 105 lines]
> > the 4 header fields by clicking on the Command Button would be greatly
> > appreciated.
Nikos Yannacopoulos - 11 Jan 2005 12:51 GMT
Patrick,
Glad you cracked it. The reason why you got 'Invalid use of Me keyword'
is the sub OpenNextForm sitting in a general module rather than the
form's own module. This was the natural thing to do on your part, the
sub intended to work with several forms, and the mistake was all mine
for overseeing this obvious fact. In order to work, the guilty code
section should be changed to:
'new section
With Forms(frmName)
.studyday = Forms(strName).studyday
.patient = Forms(strName).patient
.pat_init = Forms(strName).pat_init
.site = Forms(strName).site
End With
'end of new section
Regards,
Nikos
> Hi Nikos (and all),
>
[quoted text clipped - 112 lines]
>>>the 4 header fields by clicking on the Command Button would be greatly
>>>appreciated.
Pat Dools - 11 Jan 2005 03:31 GMT
Hi Nikos,
I found that by having the 'initial' form open (which it does on database
startup) that the code will execute properly. Thanks for your help on this
one-- you helped me think out where my bugs were and how to address them.
Thanks again,
Patrick
> Pat,
>
[quoted text clipped - 105 lines]
> > the 4 header fields by clicking on the Command Button would be greatly
> > appreciated.