0
votes

i am new to programming field for MS Access and VBScript.

I have a question that need help from here.

first of all i have 2 tables in my MS Access database. 1 is Web, 1 is Owner. Relationship is 1 to many (1 web can have multiple owners)

I have a form which consists of 3 comboboxes. combobox1 is use for webURL combobox2 is use for ownername1 combobox3 is use for ownername2

So, how can I make combobox2 and combobox3 to display the ownername1 and ownername2 respectively when I select different webURL (in combobox1). Furthermore, this combobox2 and combobox3 drop down list must include all the ownername in table Owner (So that i can change the ownername to other person of that particular web when i click the button update)

Now i only able to populate webURL data into combobox1. The rest i have no idea how to do..

Here is the sample data:

Web Table

follow the format

webID (PK), webURL

1 Stackoverflow.com

2 Google.com

3 Yahoo,com

Owner Table

follow the format

ownerID (PK), ownerName, webID (FK)

1 Law 1

2 Hans 1

3 Kent 2

4 Howard 3

5 William 3

Your help is very much appreciate in here.

Thanks!

2
How do you determine which owner is ownername1 and which is ownername2? This might be clear if you show us a brief set of sample data. - HansUp
@HansUp i am sorry that i am not able to post images on my post as i dun have enough reputation. I edited my post with some brief data, i hope u understand. Thanks! - Law

2 Answers

0
votes

Try using a the combobox.rowsource = feature. Here's a quick example...

Private Sub Test_Combo1_Click()
'when a value is selected or clicked from combobox1 then'

Dim var As String

'take the ID'
var = Me.Test_Combo1.Column(0)
Debug.Print var

'and use SQL statement to grab the corresponding link'
Me.Test_Combo2.RowSource = "Select ID, Link from URL where ID = " & var

End Sub
0
votes

I think you want this:

Private Sub Test_Combo1_Click()
'when a value is selected or clicked from combobox1 then'

Dim var As String

'take the ID'
var = Me.Test_Combo1.Column(0)
Debug.Print var

'and use SQL statement to grab the corresponding link'
Me.Test_Combo2.RowSource = "Select ID, Link from URL 
Me.Text_Combo2.Value = var
End Sub