Setting the value of a variable field

mjseim

Registered User.
Local time
Yesterday, 23:32
Joined
Sep 21, 2005
Messages
62
:confused: I've searched and searched... I can't seem to find anything close to this.

I have 10 sets of fields:
[Photo01date], [Photo01], [Photo01note]
[Photo02date], [Photo02], [Photo02note]
[Photo03date], [Photo03], [Photo03note]
etc...

These 10 fields are shown in my form for entry. There are default values for each field that need to be maintained in order for the reporting to work (I'm grabbing photos into my report).

If a user no longer wants this field to show up on the report the default values need to be re-entered. Rather than having the user enter the default values each time I want them to be able to click a button that will enter the default values for them.

So... I have a drop down menu that lists "01", "02", "03", etc... If the user selects a number that will determine which field will return to the defaults. For instance, if the user selects "05" then fields [Photo05date], [Photo05], [Photo05note] will all return to their default values.

The following code is obviously wrong (why I'm posting)... but hopefully it will make some sense as to what I'm trying to do.


Code:
Private Sub ReturnToDefaultButton_Click()
    Dim stFieldDate As Field
    Dim stFieldName As Field
    Dim stFieldMemo As Field
    
    Set stFieldDate.Name = "[Photo" & [ReturnToDefaultSelection] & "Date]"
    Set stFieldName.Name = "[Photo" & [ReturnToDefaultSelection] & "]"
    Set stFieldMemo.Name = "[Photo" & [ReturnToDefaultSelection] & "Note]"

    stMsgBoxPrompt = "Are you certain you want to return the following fields to default:" & _
    vbNewLine & stFieldDate & _
    vbNewLine & stFieldName & _
    vbNewLine & stFieldMemo
    
    If [ReturnToDefaultSelection] <> "" Then
        prompt = MsgBox(stMsgBoxPrompt, vbOKCancel + vbQuestion, "Are you sure?")
        
        If response = vbCancel Then
            Exit Sub
                        
        Else
            'Here is where the code goes to paste the lengthy path
            stFieldDate = ""
            stFieldName = "\Daily Calendar Database - White.jpg"
            stFieldNote = ""
        End If
        
    Else
        prompt = MsgBox("You must select a field number", vbOKOnly+ vbCritical, "Action canceled")
        Exit Sub
    End If
        
End Sub
 

Users who are viewing this thread

Back
Top Bottom