A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

combo box column compared



 
 
Thread Tools Display Modes
  #1  
Old October 31st, 2008, 10:11 PM posted to microsoft.public.access.forms
redFred
external usenet poster
 
Posts: 52
Default combo box column compared

I swear that I've done this, but maybe not!

I wish to compare a combo box selection's column(4) to an entry control.

The combo box is bound and returns 7 columns (I know about 0 column
counter). I am only concerned here with column 4 as that is an amount of an
invoice.

User enters into a different control a receipt amount.

I wish to test the entered receipt amount against the selected column amount.

Example:

if me.[txtReceipt] me.[cboInvoice].column(4) ... do something.

How do I do this? I have no clue.

Thanks.
--
redFred
  #2  
Old October 31st, 2008, 10:41 PM posted to microsoft.public.access.forms
Beetle
external usenet poster
 
Posts: 1,254
Default combo box column compared

It depends. If you don't want the value in txtReceipt to be committed to
the table unless it meets certain criteria, then you would use the
Before Update event of txtReceipt. For example;

Private Sub txtReceipt_BeforeUpate (Cancel As Integer)

If Me.txtReceipt Me.cboInvoice.Column(4) Then
MsgBox "Value entered is too high"
Cancel = True
End If

End Sub


On the other hand, if you want to let the value be committed to the table
and just compare it, then use the After Update event of txtReceipt i.e.;

Private Sub txtReceipt_AfterUpdate

If Me.txtReceipt Me.cboInvoice.Column(4) Then
do something...
Else
do something else
or do nothing
End If

End Sub

--
_________

Sean Bailey


"redFred" wrote:

I swear that I've done this, but maybe not!

I wish to compare a combo box selection's column(4) to an entry control.

The combo box is bound and returns 7 columns (I know about 0 column
counter). I am only concerned here with column 4 as that is an amount of an
invoice.

User enters into a different control a receipt amount.

I wish to test the entered receipt amount against the selected column amount.

Example:

if me.[txtReceipt] me.[cboInvoice].column(4) ... do something.

How do I do this? I have no clue.

Thanks.
--
redFred

  #3  
Old November 1st, 2008, 12:02 AM posted to microsoft.public.access.forms
redFred
external usenet poster
 
Posts: 52
Default combo box column compared

Thanks Beetle. You have confirmed that the following should work. I thought
it was at one time -- it does not now. Allows any amount to be entered.

Code:

Private Sub txtAmount_BeforeUpdate(Cancel As Integer)
Dim msgTooMuch, style, title, response As String
title = "Invalid Request!"
style = vbOKOnly
msgTooMuch = "Amount exceeds invoice price."

'checks for amount more than invoice
If Me.txtAmount Me.cboInvNum.Column(4) Then
response = MsgBox(msgTooMuch, style, title)
Me.txtAmount.SetFocus
Cancel = True
Me.txtAmount.Undo
End If

End Sub

I thought this was working, but maybe I changed something without realizing.
What could make it not make the comparison?

I ran debug and the comparison is skipped...even when [txtAmount] exceeds
[cboInvNum].column(4).

Any ideas?

--
redFred






"Beetle" wrote:

It depends. If you don't want the value in txtReceipt to be committed to
the table unless it meets certain criteria, then you would use the
Before Update event of txtReceipt. For example;

Private Sub txtReceipt_BeforeUpate (Cancel As Integer)

If Me.txtReceipt Me.cboInvoice.Column(4) Then
MsgBox "Value entered is too high"
Cancel = True
End If

End Sub


On the other hand, if you want to let the value be committed to the table
and just compare it, then use the After Update event of txtReceipt i.e.;

Private Sub txtReceipt_AfterUpdate

If Me.txtReceipt Me.cboInvoice.Column(4) Then
do something...
Else
do something else
or do nothing
End If

End Sub

--
_________

Sean Bailey


"redFred" wrote:

I swear that I've done this, but maybe not!

I wish to compare a combo box selection's column(4) to an entry control.

The combo box is bound and returns 7 columns (I know about 0 column
counter). I am only concerned here with column 4 as that is an amount of an
invoice.

User enters into a different control a receipt amount.

I wish to test the entered receipt amount against the selected column amount.

Example:

if me.[txtReceipt] me.[cboInvoice].column(4) ... do something.

How do I do this? I have no clue.

Thanks.
--
redFred

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:32 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.