Created a form in my test database.
Bound to text(1)
Rowsourcetype = List
Rowsource= "M","Male","F","Female"
Bound to 1
ControlSource = Test_Sex
Stored the value selected without issues.
So you have any events attached to the control?
... lets look at the control properties...
Insert a standard vba modal.
Cut and past the following:
- Option Compare Database
-
Option Explicit
-
-
Public Function LstFrmCtrlPrprtys(z_in_formname As Form, z_in_ctrlname As String)
-
Dim zform As Form
-
Dim zctrl As Control
-
Dim zprp As Property
-
Dim zFreeFile As Integer
-
Dim zTxtFile As String
-
Dim zflag As Boolean
-
'
-
On Error GoTo ZErrorTrap
-
If IsNull(z_in_formname) Or (z_in_ctrlname + "" = "") Then
-
LstFrmCtrlPrprtys = False
-
Err.Raise 9999
-
End If
-
zflag = False
-
'
-
LstFrmCtrlPrprtys = True
-
'
-
Set zform = z_in_formname
-
Set zctrl = zform.Controls.Item(z_in_ctrlname)
-
zctrl.SetFocus
-
'
-
zTxtFile = Environ("Userprofile") & "\documents\PrptyLst" & Format(Now(), "yyyymmddhhmmss") & ".txt"
-
Debug.Print "FileLocation=" & zTxtFile
-
zFreeFile = FreeFile
-
Open zTxtFile For Output As zFreeFile
-
'
-
Print #zFreeFile, "[PrprtyName]"; Tab(25); "[PrprtyType]"; Tab(38); "[PrprtyValue]"
-
zflag = True
-
For Each zprp In zctrl.Properties
-
With zprp
-
Print #zFreeFile, .Name; Tab(25); .Type; Tab(38); .Value
-
End With
-
Next zprp
-
zflag = False
-
'
-
ZErrorCleanUp:
-
'
-
Close zFreeFile
-
If Not zctrl Is Nothing Then Set zctrl = Nothing
-
If Not zform Is Nothing Then Set zform = Nothing
-
'the following will sometimes cause the code to fail
-
'If CurrentProject.AllForms(z_in_formname.Name).IsLoaded Then DoCmd.Close Objecttype:=acForm, ObjectName:=z_in_formname.Name
-
Exit Function
-
ZErrorTrap:
-
If zflag Then
-
Debug.Print "*", zprp.Name, Err.Number, Err.Description
-
Print #zFreeFile, "*", zprp.Name, Err.Number, Err.Description
-
Resume Next
-
Else
-
MsgBox Err.Number & ", " & Err.Description
-
If Err.Number = 9999 Then Exit Function
-
LstFrmCtrlPrprtys = False
-
If Not LstFrmCtrlPrprtys Then Exit Function
-
Resume ZErrorCleanUp
-
End If
-
'
-
' to use,<Ctrl><G> enter
-
'?lstfrmctrlprprtys(form_frm_formname,"z_ctrl_txtbx_nameofctrl")
-
'where form_frm_formname is the form as a form object
-
'"z_ctrl_txtbx_nameofctrl" is the name of the control on the form
-
End Function
Look at the last comment line for example of usage.
I have a form named "frm_customdbprop" in the vba object tree it is listed as "form_frm_customdbprop" so that is what I enter the line and the following is returned:
<ctrl><g>
- ?lstfrmctrlprprtys(form_frm_customdbprop,"z_ctrl_txtbx_filelocation")
-
FileLocation=C:\Users\zmbd\documents\PrptyLst20150715125440.txt
-
* InSelection 2187 This property is available only in Design view.
-
True
The file path is right there so you can C&P into windows-explorer navigation.
I use this in one of my documenting codes hence the true/false return at the end
It should drop a file in your documents folder modify the zTxtFile string as needed for your system.
Attach the text file that this creates and we can take a much deeper look at the control.
:)