Help, I’m stuck and out of my depth again.
I am trying to use an option group on a data entry form to switch between a text field and an OLE object field.
The fields sit on top of each other but only one can be visible at any one time.
If the user want to switch to the other field type I need to clear any data entered in the other field
(double checking with a message box that the user is certain this is what they want to do.)
The reason for doing this due to lack of space on the report.
I am hoping that the text field and OLE field can occupying the same space on the report, but only one will displayed, based on there being data for that field in the record.
Only one of the fields can contain data for any one record, not both.
The example below is based on a table called tblSites which contain three fields, the record ID, SiteText (the text field) and SiteObject (the OLE field).
Private Sub FrameTextOrObject_AfterUpdate()
********************************************************************
Alter the behaviour of the form acording to the option chosen. i.e The
chosen option becomes enable whilst the other is disabled
Dim response as Byte
Select Case Me!FrameTextOrObject
Case 1 ‘choose the text field option
Dim response As Byte
response = MsgBox(“Changing the data type to TEXT will overwrite the object you have just entered. Are you sure you want to do this?”, vbYesNo + vbQuestion, “Change option”)
If response = vbNo Then
Exit Sub
Else
‘some code to delete the object in SiteObject (OLE field)
End If
Me.SiteObject.Visible = False
Me.SiteText.Visible = True
Case 2 ‘choose the OLE field option
Dim response As Byte
response = MsgBox(“Changing the data type to OBJECT will overwrite the text you have just entered. Are you sure you want to do this?”, vbYesNo + vbQuestion, “Change option”)
If response = vbNo Then
Exit Sub
Else
‘some code to delete any text entered in SiteText (text field)
End If
Me.SiteText.Visible = False
Me.SiteObject.Visible = True
End Select
End Sub