From: BobbyDazzler on 19 Mar 2010 09:55 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
From: Armen Stein on 19 Mar 2010 10:20 On Fri, 19 Mar 2010 06:55:21 -0700 (PDT), BobbyDazzler <david.a.mitchell(a)inbox.com> 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
From: BobbyDazzler on 19 Mar 2010 16:39 On Mar 19, 2:20 pm, Armen Stein <ArmenSt...(a)removethisgmail.com> wrote: > On Fri, 19 Mar 2010 06:55:21 -0700 (PDT), BobbyDazzler > > > > <david.a.mitch...(a)inbox.com> 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
From: Bob Quintal on 19 Mar 2010 17:59 BobbyDazzler <david.a.mitchell(a)inbox.com> wrote in news:fbe04af4-ee38-4830-b557-47aa962d5586(a)15g2000yqi.googlegroups.com : > 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.
From: BobbyDazzler on 19 Mar 2010 19:28
> 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! |