Set multiple default values within a datasheet layout

brucey54

Registered User.
Local time
Today, 00:50
Joined
Jun 18, 2012
Messages
155
Hi folks, how do I set multiple default values within a datasheet lay out.

I would like the datasheet to display 3 default values i.e.

Column Name - CakeName

Default value 1 Chocolate Cake

Default value 2 Strawberry Cake

Default value 3 Toffee Cake
 
You can only have one default value at a time.
Do you mean a combobox with 3 values in?
 
Hi JHB, I was kind of hoping I could set multiple default values within a datasheet view. I don't think a combo work would work!
I need the students to complete each record i.e. enter each Ingredients they used for each cake...
 
Could you show a printscreen of what you exactly want, maybe it is a way around!
 

Attachments

  • Student.png
    Student.png
    48.9 KB · Views: 256
is the datasheet below a separate table?
 
Yes, I have 2 tables, 1 for student details and one for cakes details
 
your cake detail table should have a field (StudendID Long). so we know to student this cake is for.
if you already have done that, add the new field in your datasheet view (must).
if you dont want to show it, use the subforms open event:

private sub form_open(cancel as integer)
me.StudentID.ColumnHidden = True
end sub

back to design view.
click on the cake detail subform.
on the property sheet->data:

Link Master Fields: ID
Link Child Fields: StudentID

select your main form (click on the square).
add this on the main form's current event:

Private Sub Form_Current()
Dim rs As DAO.recordSet
If Not Me.NewRecord Then
Set rs = Me.tblCakeSubform.Form.RecordsetClone
With rs
If .RecordCount = 0 Then
.AddNew
![StudentID] = Me.ID
![Cake] = "Chocolate Cake"
.Update
.AddNew
![StudentID] = Me.ID
![Cake] = "Strawberry Cake"
.Update
.AddNew
![StudentID] = Me.ID
![Cake] = "Toffe Cake"
.Update
End If
.Close
End With

End If
End Sub
 
Thanks arnelgp, just one wee issue, the subform does not display the cake names until I close the subform then reopen the form!
 
should display immediately, if you set the subforms property:

Link Master Fields and Link Child Fields.

if you are adding new student it will not show, until you save that student record and go back to it.
 

Users who are viewing this thread

Back
Top Bottom