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 » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

YES/NO FIELD IN COMBOBOX



 
 
Thread Tools Display Modes
  #1  
Old March 19th, 2010, 01:55 PM posted to microsoft.public.access
BobbyDazzler
external usenet poster
 
Posts: 9
Default 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  
Old March 19th, 2010, 02:20 PM posted to microsoft.public.access
Armen Stein[_2_]
external usenet poster
 
Posts: 157
Default 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  
Old March 19th, 2010, 08:39 PM posted to microsoft.public.access
BobbyDazzler
external usenet poster
 
Posts: 9
Default 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  
Old March 19th, 2010, 09:59 PM posted to microsoft.public.access
Bob Quintal
external usenet poster
 
Posts: 939
Default 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  
Old March 19th, 2010, 11:28 PM posted to microsoft.public.access
BobbyDazzler
external usenet poster
 
Posts: 9
Default 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  
Old March 19th, 2010, 11:42 PM posted to microsoft.public.access
BobbyDazzler
external usenet poster
 
Posts: 9
Default 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  
Old March 20th, 2010, 11:55 AM posted to microsoft.public.access
Bob Quintal
external usenet poster
 
Posts: 939
Default YES/NO FIELD IN COMBOBOX

BobbyDazzler wrote in news:8f09b203-
:

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?


no actually, that is working code
Visual basic always reduces an IF statement to If Not False then
False is a constant which is 0. Any non 0 value is therefore True
Me!cboSelect.Column(2) = True gets evaluated and reduced to
Not False = Not False which is further evaluated to Not False.
but Me!cboSelect.Column(2) is already Not False, so writing it as I
have above saves 3 evaluations


* *Me!chkCustomerAcctHeld = True
* *Mew!txtsaletype = "CREDIT SALE"


is this a typo?


yes, sorry. fingers faster thgan brain.

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!

From your reply to yourself, I think you should go into the Visual
Basic Menu - Tools - Options - Editor and check Require Variable
Declaration. That probably would have given you an error at compile
time.


--
Bob Quintal

PA is y I've altered my email address.
 




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 05:35 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.