Default Values

sheepchild

New member
Local time
Today, 03:32
Joined
Feb 23, 2024
Messages
3
I have a random issue which i cant work out

i have a look up
Code:
=DLookUp("MinFaculty","tbl_CourseNames","ID=" & [EventTitleCombo])
which works in a text box under the control source and show the correct value i want

but i want this in the default value with the control source [MinNoFaculty]

but when i do it just shows blank???

what am i missing? any help would be great!
 
the controlSource of your Textbox is an Expression.
Remove it and use the Current event and AfterUpdate event of your Combobox of your Form:


Private sub Form_Current()
If Me![EventTitleCombo].ListIndex < 0 Then
Me.TheTextbox = [MinNoFaculty]
Else
Me.TheTextbox = DLookUp("MinFaculty","tbl_CourseNames","ID=" & [EventTitleCombo])
End If
End Sub

Private Sub EventTitleCombo_AfterUpdate()
Call Form_Current
End Sub
 
the controlSource of your Textbox is an Expression.
Remove it and use the Current event and AfterUpdate event of your Combobox of your Form:


Private sub Form_Current()
If Me![EventTitleCombo].ListIndex < 0 Then
Me.TheTextbox = [MinNoFaculty]
Else
Me.TheTextbox = DLookUp("MinFaculty","tbl_CourseNames","ID=" & [EventTitleCombo])
End If
End Sub

Private Sub EventTitleCombo_AfterUpdate()
Call Form_Current
End Sub
Oooooh thank you. if i wanted extra defaults such as maxCandidates (same look up how would this work as it all set via the combo box as apose each text box its being posted too?

tried a few things but keep getting errors

thank you again massive step forward for me
 
Oooooh thank you. if i wanted extra defaults such as maxCandidates (same look up how would this work as it all set via the combo box as apose each text box its being posted too?

tried a few things but keep getting errors

thank you again massive step forward for me
Think i have managed it!


Code:
Private Sub Form_Current()
    If Me![EventTitleCombo].ListIndex < 0 Then
        Me.MinNoFaculty = [MinNoFaculty]
    Else
        Me.MinNoFaculty = DLookup("MinFaculty", "tbl_CourseNames", "ID=" & [EventTitleCombo])
        Me.MaxNoDelegates = DLookup("MaxCandidates", "tbl_CourseNames", "ID=" & [EventTitleCombo])

    End If
End Sub

i was putting in the top bit twice at the top thinking that i would need to specify each text box its was filling out.
 
Hi. Welcome to AWF!

Just curious, have you tried using DLookup() in the Default Value property of each Textbox?
 

Users who are viewing this thread

Back
Top Bottom