Setting Default Values Using VBA

kermit5

Registered User.
Local time
Today, 23:12
Joined
Nov 2, 2001
Messages
122
I am creating a wizard that enables the user to select fields for a form. One of the steps in the wizard is to set the default values for the field. The numeric fields are not a problem, but I am having difficulty with alpha fields. Here is my code:


'Set Default Values
If IsNull(rstSelectedField.Fields("DefaultValue")) Then
If Not IsNull(rstSelectedField.Fields("FieldDefaultValue")) Then
ctlControl.DefaultValue = rstSelectedField.Fields("FieldDefaultValue")
End If
Else: ctlControl.DefaultValue = rstSelectedField.Fields("DefaultValue")
End If


The problem is this: If I enter L for my default value, L is saved in the selected fields table in the FieldDefaultValue. This value is then entered into the default value property of the control on the form What I need it to do is enter "L" in place of L. How do I get the quotation marks around the value?

Thanks
Scott
 
I'm totally not looking (or even thinking) this over so I may be WAAAAAAYYYYYY off base. But are you saying you need to do this:


'Set Default Values
If IsNull(rstSelectedField.Fields("DefaultValue")) Then
If Not IsNull(rstSelectedField.Fields("FieldDefaultValue")) Then
ctlControl.DefaultValue = "'" & rstSelectedField.Fields("FieldDefaultValue") & "'"
End If
Else: ctlControl.DefaultValue = "'" & rstSelectedField.Fields("DefaultValue") &"'"
End If

?
 
resolved

Yes. That is what I needed. A slight oversight on my part...:eek:

Thanks for the help.

Scott
 

Users who are viewing this thread

Back
Top Bottom