Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loop through data entry forms i times 3

Status
Not open for further replies.

Oliver2003

Technical User
Apr 19, 2003
144
GB
I have two forms that I use to input data into a ms access databse. Both the forms put in one record
e.g. some info is entered in the first form, then you click next, enter info in the second form, clcik OK and all the info is entered into one record.

What I would like to do is do this a number of times i.e if I had 5 records to enter you would set i=5 and it would loop around the above e.g. five times entering 5 records.

If I just had one form to enter data, I could use a do loop and the form.show vbmodal property,

But how can this be done with two or more forms form?



 

The simplest way I can think of is to have your forms call each other untill user says there are no more records to enter...

MainForm>User Selects DataEntry Option
DataEntryForm1>Users enters data, clicks next, validation on information and if ok
DataEntryForm2>User Enters Data, Clicks OK, Validation, Record Entry
Prompt User (in some manner) more records? If Yes then
DataEntryForm1>Users Enters Data, ....

Good Luck

 
or use a global variable. Increment it when they fill in the form, and quit the program once the variable has reached 5, or whatever the limit the user has set.
 
Set a global variable as NumOfRecords. When you start the app, have the user enter a value into an input box, of how many entries they wish to add.

Everytime the OK button is clicked on the second form, have a counter increment by one. In the sub for the second form OK button, have an if code to find out if the counter = total number of records. If this statement is true, then display a msgbox to say data entry complete, else load form 1 again.

You need to make sure you include an exit button though on both pages, otherwise, if your user enters 99 instead of 9, they will extremely annoyed, and enter false data to complete the process.

Have you considered using two frames on the same form, and then use the visible command to swop between the two. This would also mean that the forms didn't jump around the screen, you could use the same buttons, and include a label to act as a counter, with a lot less code.

BB
 
yours was much more descriptive and helpful though, Oliver should reward you the star if he uses this solution.
 
Thanks for the replys, I had got the following code working just befor you posted:

The "Next" button on each form adds the record closes the form,

Public Sub AddRecords(NumberOfRecords As String)
Do Until NumberOfRecords = 0
frmCheckNumber.Show vbModal
frmEnterInfo.Show vbModal
NumberOfRecords = NumberOfRecords - 1
Loop
End Sub

I will try your idea BiggerBrother of usng two frames on the same form.

Cheers

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top