Hi Andi,
THANK YOU for the debugging hint. I'm fairly proficient at Access, but not
so much at coding, and setting the breakpoints and then stepping thru was
really helpful. The code moves along fine w/ no errors in the sequence I
would expect my header fields on the 'next' form to be populated, but it
simply opens the form, but those header fields remain blank. If you don't
mind following along, here's the sequence:
1) Private Sub Next_Click()
On Error GoTo Err_Next_Click
Call OpenNextForm(Me.Name)
Exit_Next_Click:
Exit Sub
Err_Next_Click:
DoCmd.Close acForm, Me.Name
Resume Exit_Next_Click
End Sub
2) Calls 'OpenNextForm':
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
DoCmd.Close acForm, strName
OpenNextForm_Err:
'MsgBox Err.Description
Resume Next
End Sub
3) The above opens the next form in the seuence based on a lookup to a
table. That next form opens, and in the 'On Current:' adn 'SetAutoValues'
sub is called as follows:
Private Sub Form_Current()
Call SetAutoValues(Me)
End Sub
Sub SetAutoValues(frm As Form)
On Error GoTo SetAutoValues_err
' Set Automatic Values in each form in series
' Add as many fields as necessary (make sure each field has the same
name on EVERY form)
With frm
!studyday = Forms!fScrEligCriteria!studyday
!patient = Forms!fScrEligCriteria!patient
!pat_init = Forms!fScrEligCriteria!pat_init
!site = Forms!fScrEligCriteria!site
End With
SetAutoValues_err:
Resume Next
End Sub
4) It steps thru all four fields, looking at those equivalent fields on the
'initial' form named in the code, then closes the active form and leaves the
'next' form in series open. Its working exactly the way I want it to, but
just not populating those four fields. I've tried everything, including
wiping out all test data except for one record, and still clicking on the
'Next' button opens the 'next' form, but will not auto-populate the four
header fields based on what is present on the first form of that series.
What could I be doing wrong? I don't want to gobble up too much time, but if
there's an obvious mistake, I would love to find it.
Thank you.
Andi Mayer said:
you can skip the call
go to this line
press F9 (set breakpoint)
run the form and go step by step with F8 to see what the code is doing