Help with buttons

Fisher31

Registered User.
Local time
Today, 20:41
Joined
Oct 7, 2009
Messages
11
Hi

I am relatively new to using Access and I'm having a problem, I am setting a form up and need an option button that when selected a combo box is activated and can be used (I hope this makes sense)

The reason I need this is because on the form I'm setting up I have two lookup boxes but I want the "imputter" to only be able to choose from one of the boxes.

I don't know if this is a hard problem or a simple one but any help would be greatly appreciated
 
I think I get where you are going - If the option button is Checked then the combobox1 can be used if unchecked then combobox2.
This is fairly easy but can I ask why not use the same Combobox for both functions - All a combo box is is a "list" of data
You can change the "list" at any time with some code instead of having two in the form

Which way you want to go?
 
Hi dcd,

Thank you for repling,

I would use one combo box but the lists I need are from two different databases, can I have a two fields from two different databases in the same combo box?
 
From two different "databases" or from two different tables in your single database?
 
Sorry from two different tables within the same database
 
Hi dcd,

Thank you for repling,

I would use one combo box but the lists I need are from two different databases, can I have a two fields from two different databases in the same combo box?

You could use a union query if you want both the tables to be in the combobox at the same time or you could change the query behind the combobox
 
You could use a union query if you want both the tables to be in the combobox at the same time or you could change the query behind the combobox


I am trying to change the query behind the combobox but dont seem to be able to do it,
 
Hi

Try something like this:


Code:
Private Sub Option9_AfterUpdate()
    Dim sql As String
    If Me.Option9 = True Then
        sql = "SELECT tblLinkTestMain.MainID, tblLinkTestMain.MainText " & _
                "FROM tblLinkTestMain " & _
                "ORDER BY tblLinkTestMain.MainText;"
    Else '' Me.Option9 = False
        sql = "SELECT tblLinkTestSub.SubID, tblLinkTestSub.SubText " & _
                "FROM tblLinkTestSub " & _
                "ORDER BY tblLinkTestSub.SubText;"
    End If
    
    Me.Combo7.RowSource = sql
    Me.Combo7.Requery
    
End Sub

Of course there are a few other options you may need to adjust
Column Widths
Control Source
Column Count
ETC

Hope this makes sense - sitting at work thoughtI would just give you a quick example to get you going

Cheers
 
Hi

Try something like this:


Code:
Private Sub Option9_AfterUpdate()
    Dim sql As String
    If Me.Option9 = True Then
        sql = "SELECT tblLinkTestMain.MainID, tblLinkTestMain.MainText " & _
                "FROM tblLinkTestMain " & _
                "ORDER BY tblLinkTestMain.MainText;"
    Else '' Me.Option9 = False
        sql = "SELECT tblLinkTestSub.SubID, tblLinkTestSub.SubText " & _
                "FROM tblLinkTestSub " & _
                "ORDER BY tblLinkTestSub.SubText;"
    End If
 
    Me.Combo7.RowSource = sql
    Me.Combo7.Requery
 
End Sub

Of course there are a few other options you may need to adjust
Column Widths
Control Source
Column Count
ETC

Hope this makes sense - sitting at work thoughtI would just give you a quick example to get you going

Cheers


Im really sorry, where do I put this and what would I need to change?
I really appriciate your help
 
Hi

Why not post your db - if its still got no data - and I will show you
Just tell me what form , button, box etc then you can have a look at a working example

Cheers
 
I tried uploading it but it exceeds the download limit as it 1.2mb, :mad:
 
if I was to write a union query and wanted the "company name" field to appear from two different tables i.e. "customer details table" and "supplier details table" in one list box on a form (say called “company contact details form”)what would I write in the SQL screen? Also am I using this right as I need it in a form and want to be able to select from the list and it added to a field on my “company contact details table”

I hope this makes sense
 
I tried uploading it but it exceeds the download limit as it 1.2mb, :mad:
Did you

1. Run Compact and Repair first?

2. Zip it (you can by right-clicking on the file and selecting SEND TO > COMPRESSED FOLDER.
 
I hope I have uploaded the database im talking about
 
I hope I have uploaded the database im talking about

Nope, didn't work. When you tried uploading, you select the Manage Attachments button (you have to be in Advanced mode here for that - check to see if there is a manage attachments button down the page almost at the bottom (maybe bottom 1/3rd of the page) and then click that, the dialog opens and then you browse to the file you want and then click the UPLOAD button. It then shows the file as having been uploaded (or gives you an error) and then you can click CLOSE on that dialog and then hit Submit for the post.
 

Users who are viewing this thread

Back
Top Bottom