repeating

tubar

Registered User.
Local time
Today, 11:56
Joined
Jul 13, 2006
Messages
190
i click a command button and it prints a report...it then goes to the next record and prints that report.

DoCmd.OpenReport "GUI spec 2", acNormal, , "[GUI ID] = " & Me.[Text16]
DoCmd.GoToRecord , , acNext
DoCmd.OpenReport "GUI spec 2", acNormal, , "[GUI ID] = " & Me.[Text16]
DoCmd.GoToRecord , , acNext

now instead of pasting the code 184 more times (thats how many records there are) can i add to the code so that it knows how many records there are and when it gets to the end it stops

the complete code is this
Private Sub Command6_Click()
On Error GoTo Err_Command6_Click


Screen.PreviousControl.SetFocus
DoCmd.OpenReport "GUI spec 2", acNormal, , "[GUI ID] = " & Me.[Text16]
DoCmd.GoToRecord , , acNext
DoCmd.OpenReport "GUI spec 2", acNormal, , "[GUI ID] = " & Me.[Text16]
----repeat---184 times

Exit_Command6_Click:
Exit Sub

Err_Command6_Click:
MsgBox Err.Description
Resume Exit_Command6_Click


End Sub
 
i think so
 
Can you write this code or would you like some more assistance?
 
Okay, try this code:
Code:
Private Sub Command6_Click()
   On Error GoTo Err_Command6_Click

   With Me.Recordset
      .MoveFirst
      Do While Not .EOF
         DoCmd.OpenReport "GUI spec 2", , , "[GUI ID] = " & Me.[Text16]
         .MoveNext
      Loop
   End With

Exit_Command6_Click:
   Exit Sub

Err_Command6_Click:
   MsgBox Err.Description
   Resume Exit_Command6_Click


End Sub
 
works like a champ....thank you very much
 

Users who are viewing this thread

Back
Top Bottom