Is this combo box code remotely correct?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello, I hope you can help me here. I have never programed in MS Access before although I have programed in ASP (several years ago) so I 'm basicly a newbie. I don't know if I have anything correct and I'm not sure what I'm supposed to put in the form property's boxes, so any and all help is appreciated. I'm trying to make one combo box change based on the entry of another.

The first como box is called position the second is called crewname. If calling on queries is easier, I can to that too. This is what I have thus far, but it doesn't seem to work at all. And do I need to change any code for the second combo box? Also I get a Compile error: Method or data member not found. It highlights ".crewname" after the final End if

Private Sub position_AfterUpdate(
On Error GoTo Err_position_Clic
Dim name_sel As Strin
If position = "HAC" The
name_sel = "SELECT Pilots.name FROM Pilots WHERE Pilots.ac command = Yes ORDER BY Pilots.name;
If position = "Co-Pilot" The
name_sel = "SELECT Pilots.name FROM Pilots ORDER BY Pilots.name;
If position = "Crewchief" The
name_sel = "SELECT Aircrew.name FROM Aircrew WHERE Aircrew.crewchief = Yes ORDER BY Aircrew.name;
If position = "Second Crew" The
name_sel = "SELECT Aircrew.name FROM Aircrew ORDER BY Aircrew.name;
If position = "Corpsman" The
name_sel = "SELECT Corpsman.name FROM Corpsman ORDER BY Corpsman.name;
If position = "Guest" The
name_sel = "SELECT Guest.name FROM Guest ORDER BY Guest.name;
End I
End I
End I
End I
End I
End I
Me.crewname.RowSource = name_se

Err_position_Click
MsgBox Err.Descriptio
Resume Exit_position_AfterUpdat
End Su

Again Thank you
 
Your code is not syntactically correct for VBA....

But here is a web site that shows you how to tie two combo boxes together
such that one is filtered based on the value of the first:

The Access Web
http://www.mvps.org/access/forms/frm0028.htm

This is a simple, effective approach.

--
Ken Snell
<MS ACCESS MVP>

billyp1970 said:
Hello, I hope you can help me here. I have never programed in MS Access
before although I have programed in ASP (several years ago) so I 'm basicly
a newbie. I don't know if I have anything correct and I'm not sure what I'm
supposed to put in the form property's boxes, so any and all help is
appreciated. I'm trying to make one combo box change based on the entry of
another.
The first como box is called position the second is called crewname. If
calling on queries is easier, I can to that too. This is what I have thus
far, but it doesn't seem to work at all. And do I need to change any code
for the second combo box? Also I get a Compile error: Method or data
member not found. It highlights ".crewname" after the final End if.
 
Consider using a SELECT CASE statement instead of lots of If statements that test the same variable
SELECT CASE positio
CASE "HAC
name_sel=...
CASE "Co-Pilot
name_sel=...
<etc.
END SELECT
 
Back
Top