dbTalk Databases Forums  

Synchronize Combo box with radio buttons using vba

comp.databases.ms-access comp.databases.ms-access


Discuss Synchronize Combo box with radio buttons using vba in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Shakeel
 
Posts: n/a

Default Synchronize Combo box with radio buttons using vba - 11-18-2010 , 09:07 AM






Hi,

I have following code behind one of my unbound combo box:

Dim StrSql As String
strSql = "SELECT tblCustomer.CustomerCode, tblCustomer.CustomerName,
tblCustomer.BillingAddress " & vbCrLf & _
"FROM tblCustomer;"
Me.cmbfind.RowSourceType = "Table/Query"
Me.cmbfind.RowSource = StrSql
Me.cmbfind.ColumnHeads = True
Me.cmbfind.ColumnCount = 3
Me.cmbfind.ColumnWidths = "1 in;2 in;.95 in"
Me.cmbfind.ListWidth = 4

I have also 3 radio buttons on my form

1. CustomerCode

2. CustomerName

3. BillingAddress

I want that when I click no. 1 radio button combo box shows 3 columns
as

customer code > CustomerName > BillingAddress

when I click no. 2 radio button combo box shows 3 columns as

CustomerName > customer code > BillingAddress and so on, means my
combo box columns moves according to my choice I have already program
my radio buttons, how I do this usin vba
p.s I am not willing to use multiple select statements behind each
radio button

Reply With Quote
  #2  
Old   
Salad
 
Posts: n/a

Default Re: Synchronize Combo box with radio buttons using vba - 11-18-2010 , 10:16 AM






Shakeel wrote:

Quote:
Hi,

I have following code behind one of my unbound combo box:

Dim StrSql As String
strSql = "SELECT tblCustomer.CustomerCode, tblCustomer.CustomerName,
tblCustomer.BillingAddress " & vbCrLf & _
"FROM tblCustomer;"
Me.cmbfind.RowSourceType = "Table/Query"
Me.cmbfind.RowSource = StrSql
Me.cmbfind.ColumnHeads = True
Me.cmbfind.ColumnCount = 3
Me.cmbfind.ColumnWidths = "1 in;2 in;.95 in"
Me.cmbfind.ListWidth = 4

I have also 3 radio buttons on my form

1. CustomerCode

2. CustomerName

3. BillingAddress

I want that when I click no. 1 radio button combo box shows 3 columns
as

customer code > CustomerName > BillingAddress

when I click no. 2 radio button combo box shows 3 columns as

CustomerName > customer code > BillingAddress and so on, means my
combo box columns moves according to my choice I have already program
my radio buttons, how I do this usin vba
p.s I am not willing to use multiple select statements behind each
radio button
Well, you could set the column count to 4 and set the column width to 0
on the column you don't want to display. If you can handle the order of
the field display; Code for 1, custname for 2, address for 3 as the
first column why not simply change the SQL statement. Otherwise you
might have to change the bound column property as well.

Reply With Quote
  #3  
Old   
bobh
 
Posts: n/a

Default Re: Synchronize Combo box with radio buttons using vba - 11-19-2010 , 12:58 PM



On Nov 18, 10:07*am, Shakeel <shakeel.... (AT) gmail (DOT) com> wrote:
Quote:
Hi,

I have following code behind one of my unbound combo box:

Dim StrSql As String
strSql = "SELECT tblCustomer.CustomerCode, tblCustomer.CustomerName,
tblCustomer.BillingAddress " & vbCrLf & _
"FROM tblCustomer;"
* * Me.cmbfind.RowSourceType = "Table/Query"
* * Me.cmbfind.RowSource = StrSql
* * Me.cmbfind.ColumnHeads = True
* * Me.cmbfind.ColumnCount = 3
* * Me.cmbfind.ColumnWidths = "1 in;2 in;.95 in"
* * Me.cmbfind.ListWidth = 4

I have also 3 radio buttons on my form

1. CustomerCode

2. CustomerName

3. BillingAddress

I want that when I click no. 1 radio button combo box shows 3 columns
as

customer code > CustomerName > BillingAddress

when I click no. 2 radio button combo box shows 3 columns as

CustomerName > customer code > BillingAddress and so on, means my
combo box columns moves according to my choice I have already program
my radio buttons, how I do this usin vba
p.s I am not willing to use multiple select statements behind each
radio button
if your radio buttons are radio buttons of a Group control then in the
On-click event of the Group control you can set up Select Case logic
to do this.
sample;

Dim StrSql As String
Select Case YourGroupControlName
Case 1 'customer code first
strSql = "SELECT tblCustomer.CustomerCode, tblCustomer.CustomerName,
tblCustomer.BillingAddress " & vbCrLf & _
"FROM tblCustomer;"
Me.cmbfind.ColumnWidths = "1 in;2 in;.95 in"

Case 2 'customer name first
strSql = "SELECT tblCustomer.CustomerName, tblCustomer.CustomerCode,
tblCustomer.BillingAddress " & vbCrLf & _
"FROM tblCustomer;"
Me.cmbfind.ColumnWidths = "2 in;1 in;.95 in"

Case 3 'customer billing address first
strSql = "SELECT tblCustomer.BillingAddress,
tblCustomer.CustomerName,
tblCustomer.CustomerCode" & vbCrLf & _
"FROM tblCustomer;"
Me.cmbfind.ColumnWidths = "0.95 in;1 in;2 in"

End Select

Me.cmbfind.RowSourceType = "Table/Query"
Me.cmbfind.RowSource = StrSql
Me.cmbfind.ColumnHeads = True
Me.cmbfind.ColumnCount = 3
Me.cmbfind.ColumnWidths = "1 in;2 in;.95 in"
Me.cmbfind.ListWidth = 4
' then do whatever you do next

bobh.

Reply With Quote
Reply




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 On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.