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
|
|||
|
|||
YES/NO FIELD IN COMBOBOX
tblCustomer
custid PK autonumber custname text custcode text custacct yes/no used in frminvoice as combobox using all 4 fields (custid hidden) example data in combobox A D Plumbers | AD0001 | -1 Smith, Andrew | SM0001 | 0 column(3) either shows -1 for true or 0 for false This field indicates whether the customer is an account holder or not, if they are then txtsaletype should read "CREDIT SALE" and if they aren't it should read "CASH SALE" Once a customer is selected from the drop down list I have this code running in the afterupdate event:- If Me!cboSelect.Column(3) = -1 Then Me!chkCustomerAcctHeld = -1 Else Me!chkCustomerAcctHeld = 0 End If If Me!chkCustomerAcctHeld = -1 Then txtsaletype = "CREDIT SALE" Else txtsaletype = "CASH SALE" End If It doesn't work! Where am I going wrong? Thanks David |
#2
|
|||
|
|||
YES/NO FIELD IN COMBOBOX
On Fri, 19 Mar 2010 06:55:21 -0700 (PDT), BobbyDazzler
wrote: Once a customer is selected from the drop down list I have this code running in the afterupdate event:- If Me!cboSelect.Column(3) = -1 Then Me!chkCustomerAcctHeld = -1 Else Me!chkCustomerAcctHeld = 0 End If If Me!chkCustomerAcctHeld = -1 Then txtsaletype = "CREDIT SALE" Else txtsaletype = "CASH SALE" End If It doesn't work! Where am I going wrong? What doesn't work about it? Why don't you just set the ControlSource of the txtsaletype control to: =IIF(Me!cboSelect.Column(3) = 0, "CASH SALE", "CREDIT SALE") Then you can remove all your after update code. PS - It is not advisable to use a real email address in a public newsgroup, as spammers can harvest addresses from here. Armen Stein Microsoft Access MVP www.JStreetTech.com |
#3
|
|||
|
|||
YES/NO FIELD IN COMBOBOX
On Mar 19, 2:20*pm, Armen Stein
wrote: On Fri, 19 Mar 2010 06:55:21 -0700 (PDT), BobbyDazzler wrote: Once a customer is selected from the drop down list I have this code running in the afterupdate event:- If Me!cboSelect.Column(3) = -1 Then * *Me!chkCustomerAcctHeld = -1 Else * *Me!chkCustomerAcctHeld = 0 End If If Me!chkCustomerAcctHeld = -1 Then * txtsaletype = "CREDIT SALE" Else * txtsaletype = "CASH SALE" End If It doesn't work! *Where am I going wrong? What doesn't work about it? It doesn't chamge from Yes to No and No to Yes as it should Why don't you just set the ControlSource of the txtsaletype control to: =IIF(Me!cboSelect.Column(3) = 0, "CASH SALE", "CREDIT SALE") Then you can remove all your after update code. This isn't the only place that the info can be set from. The form is used for new invoices, view invoices, view uninvoiced and view upaid invoice all with different recordsources! So needs to be this way. PS - It is not advisable to use a real email address in a public newsgroup, as spammers can harvest addresses from here. It's ok, this is my spam email address! Armen Stein Microsoft Access MVPwww.JStreetTech.com |
#4
|
|||
|
|||
YES/NO FIELD IN COMBOBOX
BobbyDazzler wrote in
: tblCustomer custid PK autonumber custname text custcode text custacct yes/no used in frminvoice as combobox using all 4 fields (custid hidden) example data in combobox A D Plumbers | AD0001 | -1 Smith, Andrew | SM0001 | 0 column(3) either shows -1 for true or 0 for false This field indicates whether the customer is an account holder or not, if they are then txtsaletype should read "CREDIT SALE" and if they aren't it should read "CASH SALE" Once a customer is selected from the drop down list I have this code running in the afterupdate event:- If Me!cboSelect.Column(3) = -1 Then Me!chkCustomerAcctHeld = -1 Else Me!chkCustomerAcctHeld = 0 End If If Me!chkCustomerAcctHeld = -1 Then txtsaletype = "CREDIT SALE" Else txtsaletype = "CASH SALE" End If It doesn't work! Where am I going wrong? Thanks David Where are you going wrong? do you want the long list or the short one? the short list is 1) .Column(n) is ZERO-based, so your columns are 0,1,2 not 1,2,3 2) you are using the literal -1 and 0 instead of True and False 3) what is txtsaletype? the name implies a textbox, which should be prefixed with Me! or Form!Name! 4) you are using multiple if-else blocks where only 1 is needed. If Me!cboSelect.Column(2) Then Me!chkCustomerAcctHeld = True Mew!txtsaletype = "CREDIT SALE" Else Me!chkCustomerAcctHeld = False Mew!txtsaletype = "CASH SALE" End If -- Bob Quintal PA is y I've altered my email address. |
#5
|
|||
|
|||
YES/NO FIELD IN COMBOBOX
Where are you going wrong? do you want the long *list or the short
one? Give me the long one! the short list is 1) .Column(n) is ZERO-based, so your columns are 0,1,2 not 1,2,3 Yeah, I know, there are four columns! 0,1,2,3 2) you are using the literal -1 and 0 instead of True and False ok, have changed 3) what is txtsaletype? the name implies a textbox, which should be prefixed with Me! or Form!Name! your right, it was in my app I retyped instead of copying and pasting 4) you are using multiple if-else blocks where only 1 is needed. If Me!cboSelect.Column(2) Then is there somthing missing on this line? * *Me!chkCustomerAcctHeld = True * *Mew!txtsaletype = "CREDIT SALE" is this a typo? Else * *Me!chkCustomerAcctHeld = False * *Mew!txtsaletype = "CASH SALE" End If Tried with Me! and with True/False and without multiple ifs and still doesn't work! |
#6
|
|||
|
|||
YES/NO FIELD IN COMBOBOX
If Me!cboSelect.Column(3) should have been If Me!cboSelectCustomer.Column(3) What a muppet! Sorry folks and thanks for the help! |
#7
|
|||
|
|||
YES/NO FIELD IN COMBOBOX
|
Thread Tools | |
Display Modes | |
|
|