Not Calling function

GavZ

Mostly Beginners Luck!
Local time
Today, 20:24
Joined
May 4, 2007
Messages
56
Hi,

I have a continuous form with a directory list of file and i want the user to tick a check box on the ones they want and click a button to import them.

The only thing not working is the below where it cycles through the form. It updates the textbox correctly but it always calls the function on the first record!

Please Help..


Code:
DoCmd.GoToRecord , , acFirst 'Goto first Record
          
With Recordset
     While .AbsolutePosition <> .RecordCount - 1 
          
          If ch.Value = True Then
            Call ImportFile
            tb_comp.Value = "Import Complete.."
          End If
          
          DoCmd.GoToRecord , , acNext
          
     Wend

          If ch.Value = True Then
             Call ImportFile
             tb_comp.Value = "Import Complete.."
          End If

End With
 
Three things:

1. Bad naming convention. Recordset is not a good name for a variable. It's a reserved keyword in Access which is one reason why nothing is happening.
2. What is the purpose of AbsolutePosition? Use Do While Not rs.EOF. To Learn more about working with recordsets, read this:
http://allenbrowne.com/ser-29.html
3. You are calling ImportFile but not passing any parameters to it. It seems repetitive and redundant. What is it doing?
 

Users who are viewing this thread

Back
Top Bottom