Can't select an item in a Combo Box

Gaufres

Registered User.
Local time
Tomorrow, 10:56
Joined
Jan 13, 2005
Messages
24
I have a sub form with a combo box. It contains three campus names for uni. I created a “Campus query” for the combo box. A correct campus name will show up but I cannot select the other campus to change it. Why is that?

Any idea?
Gaufres
 
Com Box

It would help if you post the code.

Please be patient for help and don't post your question
multiple times.
 
mmmmm I'm not sure about the code. but here is the code for the form what i have. I haven't touched anything though.. am I meant to? I just added a combo box and linked to the "Campus" query..

Thank you for a prompt reply!


Option Compare Database
Option Explicit


Private Sub cmdplacementtest_Click()
On Error GoTo Err_cmdplacementtest_Click

Dim lngStudentID

' Get the ID of the record that was clicked.
lngStudentID = Me.Controls("student_id")

' Open the form passing the UID of the record to display.
DoCmd.OpenForm "Placement Test", , , "student_id = " & lngStudentID, acFormEdit, , lngStudentID

Exit_cmdplacementtest_Click:
Exit Sub

Err_cmdplacementtest_Click:
MsgBox Err.Description
Resume Exit_cmdplacementtest_Click

End Sub


Private Sub Form_AfterInsert()

' Enable links to child functions.
Me.cmdAlumni.Enabled = True
Me.cmdHomestayRecord.Enabled = True
Me.cmdIELTSResults.Enabled = True
Me.cmdAddEnrolment.Enabled = True

End Sub

Private Sub Form_Dirty(Cancel As Integer)

Me.cmdSave.Enabled = True

End Sub

Private Sub cmdSave_Click()
On Error GoTo Err_cmdSave_Click

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Exit_cmdSave_Click:
Exit Sub

Err_cmdSave_Click:
MsgBox Err.Description
Resume Exit_cmdSave_Click

End Sub

Private Sub Form_Load()
On Error GoTo Err_Form_Load

Dim lngStudentID As Long

If (IsNull(Me.OpenArgs)) Then

lngStudentID = 0

ElseIf (Me.OpenArgs = "") Then

lngStudentID = 0

Else

lngStudentID = CLng(Me.OpenArgs)

End If

If (lngStudentID = 0) Then

' Adding a new record.
DoCmd.GoToRecord , , acNewRec
Me.first_name.SetFocus

' Diasble links to child functions. Enable in the AfterInsert handler.
Me.cmdAlumni.Enabled = False
Me.cmdHomestayRecord.Enabled = True
Me.cmdIELTSResults.Enabled = False

Else

' Editing an existing record.
Me.prospect_id.Enabled = False

End If

Exit_Form_Load:
Exit Sub

Err_Form_Load:
MsgBox Err.Description
Resume Exit_Form_Load
End Sub

Private Sub Form_Open(Cancel As Integer)

If ((IsNull(Me.OpenArgs)) Or (Me.OpenArgs = "")) Then

MsgBox "A student has not been selected for maintenance.", vbCritical Or vbOKOnly, "Error"
Cancel = True

End If

End Sub

Private Sub prospect_id_Click()
Dim rs As Object
Dim sSQL As String

CurrentDb.Execute ("INSERT INTO Prospect (temp) VALUES ('a');")

sSQL = "select max(prospect_id) as pid from Prospect;"
Set rs = CurrentDb.OpenRecordset(sSQL)

student_id = rs("pid")

Me.first_name.SetFocus
Me.prospect_id.Enabled = False

End Sub
Private Sub cmdHomestayRecord_Click()
On Error GoTo Err_cmdHomestayRecord_Click

Dim lngStudentID

' Get the ID of the record that was clicked.
lngStudentID = Me.Controls("student_id")

' Open the form passing the UID of the record to display.
DoCmd.OpenForm "Homestay Record", , , "student_id = " & lngStudentID, acFormEdit, , lngStudentID

Exit_cmdHomestayRecord_Click:
Exit Sub

Err_cmdHomestayRecord_Click:
MsgBox Err.Description
Resume Exit_cmdHomestayRecord_Click

End Sub

Private Sub cmdIELTSResults_Click()
On Error GoTo Err_cmdIELTSResults_Click

Dim lngStudentID

' Get the ID of the record that was clicked.
lngStudentID = Me.Controls("student_id")

' Open the form passing the UID of the record to display.
DoCmd.OpenForm "IELTS", , , "student_id = " & lngStudentID, acFormEdit, , lngStudentID

Exit_cmdIELTSResults_Click:
Exit Sub

Err_cmdIELTSResults_Click:
MsgBox Err.Description
Resume Exit_cmdIELTSResults_Click

End Sub

Private Sub cmdAlumni_Click()
On Error GoTo Err_cmdAlumni_Click

Dim lngStudentID

' Get the ID of the record that was clicked.
lngStudentID = Me.Controls("student_id")

' Open the form passing the UID of the record to display.
DoCmd.OpenForm "Alumni", , , "student_id = " & lngStudentID, acFormEdit, , lngStudentID

Exit_cmdAlumni_Click:
Exit Sub

Err_cmdAlumni_Click:
MsgBox Err.Description
Resume Exit_cmdAlumni_Click

End Sub

Private Sub cmdClasses_Click()
On Error GoTo Err_cmdClasses_Click

Dim lngStudentID

' Get the ID of the record that was clicked.
lngStudentID = Me.Controls("student_id")

' Open the form passing the UID of the record to display.
DoCmd.OpenForm "Classes", , , "student_id = " & lngStudentID, acFormEdit, , lngStudentID

Exit_cmdClasses_Click:
Exit Sub

Err_cmdClasses_Click:
MsgBox Err.Description
Resume Exit_cmdClasses_Click

End Sub

Private Sub cmdStatus_Click()
On Error GoTo Err_cmdStatus_Click

Dim lngStudentID

' Get the ID of the record that was clicked.
lngStudentID = Me.Controls("student_id")

' Open the form passing the UID of the record to display.
DoCmd.OpenForm "Status", , , "student_id = " & lngStudentID, acFormEdit, , lngStudentID

Exit_cmdStatus_Click:
Exit Sub

Err_cmdStatus_Click:
MsgBox Err.Description
Resume Exit_cmdStatus_Click

End Sub
Private Sub cmdClose_Click()
On Error GoTo Err_cmdClose_Click


DoCmd.Close

Exit_cmdClose_Click:
Exit Sub

Err_cmdClose_Click:
MsgBox Err.Description
Resume Exit_cmdClose_Click

End Sub
 
Yes, sorry I wanted to edit my post but somehow I posted twice.. I'll be careful next time.
Gaufres
 
Sorry

Sorry the above code that I posted is for the main form, not the sub form.. sorry I am newbie for Access VB Code and to be honest, I'm not sure what I am doing.. The sub form that has the "Campus" combo box doesn't have any code.. I have been googling but I don't know what the key word would be so I'm not getting good result..

Gaufres :(
 
No problem

May be you can attach your mdb (without sensitive data) to a new post
and I'm sure someone will take a look at it and help you solve the problem.

Zip your mdb and keep it under 100k.
 

Users who are viewing this thread

Back
Top Bottom