 |
 |
|

04-14-2003, 11:58 AM
|
|
Junior Contributor
|
|
Join Date: Apr 2003
Location: manchester
Posts: 305
|
|
simple loop
|
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:
PHP Code:
If TxtPay < 30 Then DatPay.Recordset.MoveNext
Else: MsgBox "error"
txtpay.setfocus
End If
If TxtPay < 30 Then Exit Do
Else: MsgBox "error"
txtpay.setfocus
Loop
could anyone suggest how i could get this to work please?
cheers
|
|

04-14-2003, 12:07 PM
|
 |
MetaCenturion
Retired Moderator * Guru *
|
|
Join Date: Aug 2001
Location: California, USA
Posts: 16,583
|
|
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. 
|
|

04-14-2003, 12:10 PM
|
|
Junior Contributor
|
|
Join Date: Apr 2003
Location: manchester
Posts: 305
|
|
|
no the information is in an access database
|
|

04-14-2003, 12:13 PM
|
 |
Senior Contributor
* Expert *
|
|
Join Date: Sep 2002
Location: Karlsruhe, Germany
Posts: 1,319
|
|
Also it would be better if you convert the
string from the textbox into a number like this:
Code:
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:
Code:
If Val(TxtPay(Index).Text) < 30
|
|

04-14-2003, 12:19 PM
|
|
Junior Contributor
|
|
Join Date: Apr 2003
Location: manchester
Posts: 305
|
|
simple loop with access
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:
Code:
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
|
|

04-14-2003, 12:24 PM
|
|
Newcomer
|
|
Join Date: Jul 2002
Location: Iowa
Posts: 13
|
|
|
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
|
__________________
Khamel
|

04-14-2003, 12:24 PM
|
|
Junior Contributor
|
|
Join Date: Apr 2003
Location: manchester
Posts: 305
|
|
|
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
|
|

04-14-2003, 12:52 PM
|
 |
Keeper of foo
Retired Moderator * Guru *
|
|
Join Date: Nov 2001
Location: Graceland
Posts: 15,612
|
|
|
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.
|
|

04-14-2003, 12:57 PM
|
|
Junior Contributor
|
|
Join Date: Apr 2003
Location: manchester
Posts: 305
|
|
|
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
|
|

04-14-2003, 01:03 PM
|
 |
Keeper of foo
Retired Moderator * Guru *
|
|
Join Date: Nov 2001
Location: Graceland
Posts: 15,612
|
|
|

04-14-2003, 01:05 PM
|
|
Junior Contributor
|
|
Join Date: Apr 2003
Location: manchester
Posts: 305
|
|
|
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?
|
|

04-14-2003, 01:09 PM
|
 |
Senior Contributor
* Expert *
|
|
Join Date: Sep 2002
Location: Karlsruhe, Germany
Posts: 1,319
|
|
Quote: Originally Posted by xelonite 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.
|
|

04-14-2003, 01:12 PM
|
|
Junior Contributor
|
|
Join Date: Apr 2003
Location: manchester
Posts: 305
|
|
ive tried that and a few variations including:
Code:
Do While Val(TxtPay.Text) = " "
If Val(TxtPay) < 30 Then
DatPay.Recordset.MoveNext
Else
MsgBox "error"
TxtPay.SetFocus
End If
Loop
and
Code:
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
|
|

04-14-2003, 01:14 PM
|
|
Junior Contributor
|
|
Join Date: Apr 2003
Location: manchester
Posts: 305
|
|
|
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
|
|

04-14-2003, 01:53 PM
|
 |
Senior Contributor
* Expert *
|
|
Join Date: Sep 2002
Location: Karlsruhe, Germany
Posts: 1,319
|
|
Quote: Originally Posted by xelonite 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)
|
|

04-14-2003, 01:59 PM
|
|
Junior Contributor
|
|
Join Date: Apr 2003
Location: manchester
Posts: 305
|
|
|
i want to make sure not all the text boxes just txtpay contains a number less than 30
|
|

04-14-2003, 02:13 PM
|
 |
Senior Contributor
* Expert *
|
|
Join Date: Sep 2002
Location: Karlsruhe, Germany
Posts: 1,319
|
|
OK. But doesn't the code that you posted do just that?
Code:
Private Sub Command1_Click()
If Val(txtPay.Text) < 30 Then
'Everything OK, database & Exit code here
DatPay.Recordset.MoveNext
Exit Do
Else
MsgBox "Error! txtPay >= 30 !!!"
txtPay.SetFocus
End If
End Sub
P.S. I got a little confused because you used PHP tags!
|
|

04-14-2003, 02:20 PM
|
|
Junior Contributor
|
|
Join Date: Aug 2002
Location: England
Posts: 308
|
|
|
Have you tried FindFirst/FindNext Or Seek?
|
|

04-14-2003, 02:28 PM
|
|
Junior Contributor
|
|
Join Date: Apr 2003
Location: manchester
Posts: 305
|
|
|
no the code i used just tested the txtpay text box
that code came up with an error:
compile error
Exit Do not within Do...Loop
|
|

04-14-2003, 02:37 PM
|
 |
Senior Contributor
* Expert *
|
|
Join Date: Sep 2002
Location: Karlsruhe, Germany
Posts: 1,319
|
|
Quote: Originally Posted by xelonite i want to make sure not all the text boxes just txtpay contains a number less than 30
Quote: Originally Posted by xelonite no the code i used just tested the txtpay text box
??? I'm confused. Did you try the code that I posted?
Edit: Might also be a good idea if you posted your whole
code (if it's not too long).
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|