Newbie- Textbox validation

B

Bauji

I am not a access programmer, in existing access application, there is one invoice form in which I want to put a validation on textbox (quantity) that if user can not enter more than displayed quantiry, however he can enter less quantity as displayed quantiry, othere wise an error message should displayed..

Secondly How I can use one more query in an data bound form?

So let me know how do I make it or let me know is there any good access turorial to make a correction in current application.
 
A

Arvin Meyer

In the BeforeUpdate event of the textbox try something like this (air code):

Sub txtWhatever_BeforeUpdate(Cancel As Integer)
If Me.txtWhatever > Me.txtToCompareWith Then
MsgBox " Too High"
Me.txtWhatever.SetFocus
Cancel = True
End If
End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access

I am not a access programmer, in existing access application, there is one
invoice form in which I want to put a validation on textbox (quantity) that
if user can not enter more than displayed quantiry, however he can enter
less quantity as displayed quantiry, othere wise an error message should
displayed..

Secondly How I can use one more query in an data bound form?

So let me know how do I make it or let me know is there any good access
turorial to make a correction in current application.
 
B

Bauji

I also got following error

*----------------------------------------------------------------
Runtime eror 2018:

You must save the field before you execute the gotocontrol execution
the gotocontrol method, or the setfocus method.
*----------------------------------------------------------------

Let me know how should I handle this?
 
A

Arvin Meyer

You cannot compare the count with a Controlsource. Comparing it with itself
doesn't make much sense either since it will always be equal. (or Null)

Specifically, what are you trying to do? Tell me exactly what the names of
the 2 text boxes to compare.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
B

Bauji

I am trying to compare value of displayed value and entered valued in same
textbox.
 
A

Arvin Meyer

I am not sure that I understand. The displayed value should be the same as
the entered value. If you are updating an existing record there is the
..OldValue property, which is the value of the control before the editing is
commited. You can access that in code with something like:

Sub Form_BeforeUpdate(Cancel As Integer)

MsgBox "Old Value: " & Me.txtSomeData.OldValue & ", New Value: " &
Me.txtSomeData

End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top