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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|