simple question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,

I have a text field. I want the user not to be able to enter a value in
that's greater than something in another text field.

I put this in the "after update" for the Seq_Num text box
If (Me.Seq_Num > Me.Total_Seq) Then
Me.Seq_Num = Me.Total_Seq + 1
End If

However the value in Seq_Num gets altered no matter what I put in the text
box (ie, a lower value).

I must be missing something obvious. Can someone please help me out?
 
if your sequence numbers are long integers, try this:

If (cLng(Me.Seq_Num) > cLng(Me.Total_Seq)) Then
Me.Seq_Num = Me.Total_Seq + 1
End If

TEXTboxes store ... text ...so you may need to convert them
to numbers to compare them accurately.

the reason you don't need conversion function on the math
statement is that Access will adjust data types when it
performs math.

Warm Regards,
Crystal
Microsoft Access MVP 2006

remote programming and training
strive4peace2006 at yahoo.com
*
Have an awesome day ;)
 
Perfect! Muchos Thanks

strive4peace said:
if your sequence numbers are long integers, try this:

If (cLng(Me.Seq_Num) > cLng(Me.Total_Seq)) Then
Me.Seq_Num = Me.Total_Seq + 1
End If

TEXTboxes store ... text ...so you may need to convert them
to numbers to compare them accurately.

the reason you don't need conversion function on the math
statement is that Access will adjust data types when it
performs math.

Warm Regards,
Crystal
Microsoft Access MVP 2006

remote programming and training
strive4peace2006 at yahoo.com
*
Have an awesome day ;)
 
Nick_Japan said:
Hi All,

I have a text field. I want the user not to be able to enter a value in
that's greater than something in another text field.

I put this in the "after update" for the Seq_Num text box
If (Me.Seq_Num > Me.Total_Seq) Then
Me.Seq_Num = Me.Total_Seq + 1
End If

However the value in Seq_Num gets altered no matter what I put in the text
box (ie, a lower value).

I must be missing something obvious. Can someone please help me out?

Why are they text fields if you're storing numbers? Have you tried changing
the data type to 'Number'? Alternatively you could try using the CInt
function in your code.

HTH - Keith.
www.keithwilby.com
 
you're welcome, Nick ;) happy to help

Warm Regards,
Crystal
Microsoft Access MVP 2006

remote programming and training
strive4peace2006 at yahoo.com
*
Have an awesome day ;)
 
strive4peace said:
TEXTboxes store ... text ...so you may need to convert them to numbers to
compare them accurately.

I'm sure that was just a slip of the pen but ITYM "text fields" ... unless
I'm missing something, which is entirely possible ;-)

Regards,
Keith.
www.keithwilby.com
 
Hi Keith,

I should have qualified that to UNBOUND textboxes ... if
they are bound, then, yes, the data type can be determined.
If they are not, the data is treated as text.

Warm Regards,
Crystal
Microsoft Access MVP 2006

remote programming and training
strive4peace2006 at yahoo.com
*
Have an awesome day ;)
 
strive4peace said:
Hi Keith,

I should have qualified that to UNBOUND textboxes ... if they are bound,
then, yes, the data type can be determined. If they are not, the data is
treated as text.

Warm Regards,
Crystal
Microsoft Access MVP 2006

Duly noted, thanks Crystal.

Keith.
 
you're welcome, Keith ;)


Warm Regards,
Crystal
Microsoft Access MVP 2006

remote programming and training
strive4peace2006 at yahoo.com
*
Have an awesome day ;)
 
Back
Top