i want a loop that will go through a database so once the user clicks on the "check" button it will check all of the entries for the pay rate being less than 30 if the pay is more than 30 then an error message will apear and the cursor will go to that text box in order for the user to update it

Is the data already in the database or in the form.
If it's on the form, then it'd be best if you had a control array and looped through that. :)

xelonite84

04-14-2003, 12:10 PM

no the information is in an access database

Robse

04-14-2003, 12:13 PM

Also it would be better if you convert the
string from the textbox into a number like this:

If Val(TxtPay.Text) < 30

before you do a comparison with another number.

Using Iceplug's suggestion of a control array for
your textboxes will change it into something like this:

If Val(TxtPay(Index).Text) < 30

xelonite84

04-14-2003, 12:19 PM

i want a loop that will go through a database so once the user clicks on the "check" button it will check all of the entries for the pay rate being less than 30 if the pay is more than 30 then an error message will apear and the cursor will go to that text box in order for the user to update it

ive tried a few ways including these:

If TxtPay < 30 Then DatPay.Recordset.MoveNext
Else: MsgBox "error"
End If

If TxtPay < 30 Then Exit Do
Else: MsgBox "error"
Loop

does anyone have any suggestions on how i could get this to work?

cheers

khamel

04-14-2003, 12:24 PM

cheers[/QUOTEPOST]
have you tried
do while txtpay (not sure how to get this part right) .text =! " "
if Val(txtpay) < 30 then
datpay.recordset.movenext
else
msgbox "error"
end if
loop

Sorry about the first line i am checking in my post how to do this but in theory this should work
Cassie

xelonite84

04-14-2003, 12:24 PM

that wouldnt make it work tho would it? doesnt that just improve the code in some way?

do you know where i am going wrong with my code ? or is it all wrong? i dont think it is but im not all that brilliant with vb. web programming is more my area

reboot

04-14-2003, 12:52 PM

Why not just start with the recordset containing all the entries that are more than 30? Then you simply loop through that recordset, as it already contains all the records you want to change, and none of the ones you don't.

xelonite84

04-14-2003, 12:57 PM

because there is more than 1 person who can add entries to the database although this isnt doen through the program so i need the program to just check all entries for any errors

reboot

04-14-2003, 01:03 PM

Uhhhh.... ok.

xelonite84

04-14-2003, 01:05 PM

ok that might make no sense but no i cant do that

is there no way that will just search all the entries until it comes across that field with a number equal to or over 30? then puts the curser in that field so the user can change it?

Robse

04-14-2003, 01:09 PM

i want a loop that will go through a database so once the user clicks on the "check" button it will check all of the entries for the pay rate being less than 30 if the pay is more than 30 then an error message will apear and the cursor will go to that text box in order for the user to update it

So you have multiplie textboxes? And by "entries" you mean the entries
in the textboxes? And you always want to check if they are less than
30? Or am I misunderstanding something.

and
Do While Val(TxtPay.Text) = " "
If Val(TxtPay) < 30 Then
DatPay.Recordset.MoveNext
Else
MsgBox "error"

End If
Loop
aswel as a few others but i still cant get it to work

xelonite84

04-14-2003, 01:14 PM

i do have multiple text boxes and yes the user does enter them on the program but there is also a lot of entries in the database that i want the program to check

Robse

04-14-2003, 01:53 PM

i do have multiple text boxes and yes the user does enter them on the program but there is also a lot of entries in the database that i want the program to check

Yes but I think it would be easier to first do one thing, then
the other. So do you want to make sure that all textboxes contain
values < 30 first or do you want to compare the textbox values to those
in the database first?

(BTW You really don't need the database to make sure each textbox's
value is smaller than a given number)

xelonite84

04-14-2003, 01:59 PM

i want to make sure not all the text boxes just txtpay contains a number less than 30

Private Sub cmdPrevious_Click()
DatPay.Recordset.MovePrevious
If DatPay.Recordset.BOF Then
DatPay.Recordset.MoveFirst
End If

End Sub

Robse

04-14-2003, 03:02 PM

OK I assumed you had a loop in your code.
Just remove the

Exit Do

xelonite84

04-14-2003, 03:33 PM

ok cheers

but what would i need to change in order to make it a loop?

Robse

04-14-2003, 03:44 PM

Depends on what you mean by "it".

Edit: Rephrase this:

i want a loop that will go through a database so once the user clicks on the "check" button it will check all of the entries for the pay rate being less than 30 if the pay is more than 30 then an error message will apear and the cursor will go to that text box in order for the user to update it

You say there is one txtPay that you want to check, but in that
paragraph you are saying "all of the entries for the pay rate" ?
Also how does the database fit into this?