I assume you mean you want a control on the form to have that as the default
value. I don't know if you can assign a variable's value a control's default
value property , but you can set the value of the control to that value in
your Form Open event procedure, e.g. if your control is a textbox called
txtA...
Private Sub Form_Open(Cancel As Integer)
txtA.value = gstrThisUser
End Sub
Hope this helps.
> I use the following coding to keep a salesman name for entry into a order
> entry system:
> Public gstrThisUser As String
> Is there a way to move that variable into the default value on a form? I
> have got coding to work with a interger value but cannot get it to work with
> a string value. Thanks for any help.
BGuidry - 16 Jan 2006 17:30 GMT
Jim below is the coding which is similar to yours that I am using:
Me.SalesmanName.DefaultValue = gstrThisUser
The only problem is that it returns a error. If I use a interger field
instead it will work just fine. I have tried just about everything and it
seems the problem is that it needs "" in front and behind the variable. So if
you or any one else can help with that I would greatly appreciate it.
> I assume you mean you want a control on the form to have that as the default
> value. I don't know if you can assign a variable's value a control's default
[quoted text clipped - 16 lines]
> > have got coding to work with a interger value but cannot get it to work with
> > a string value. Thanks for any help.
Ofer - 16 Jan 2006 18:07 GMT
Have you tried my suggestion?
Me.SalesmanName.DefaultValue = "'" & gstrThisUser & "'"

Signature
\\// Live Long and Prosper \\//
BS"D
> Jim below is the coding which is similar to yours that I am using:
> Me.SalesmanName.DefaultValue = gstrThisUser
[quoted text clipped - 23 lines]
> > > have got coding to work with a interger value but cannot get it to work with
> > > a string value. Thanks for any help.
On the ONLoad event of the form, write
Me.[FieldName].DefaultValue = "'" & VariableName & "'"
Add a single quote before and after the variable

Signature
\\// Live Long and Prosper \\//
BS"D
> I use the following coding to keep a salesman name for entry into a order
> entry system:
> Public gstrThisUser As String
> Is there a way to move that variable into the default value on a form? I
> have got coding to work with a interger value but cannot get it to work with
> a string value. Thanks for any help.
BGuidry - 16 Jan 2006 19:49 GMT
Thanks Ofer that did the trick. I thought I had tried that one but I guess I
was wrong. It has been awhile since I have done anything in Access so it is
nice to know there is somewhere to turn when I run into a stumper.
> On the ONLoad event of the form, write
>
[quoted text clipped - 8 lines]
> > have got coding to work with a interger value but cannot get it to work with
> > a string value. Thanks for any help.
Ofer - 16 Jan 2006 20:07 GMT
I'm glad I could help

Signature
\\// Live Long and Prosper \\//
BS"D
> Thanks Ofer that did the trick. I thought I had tried that one but I guess I
> was wrong. It has been awhile since I have done anything in Access so it is
[quoted text clipped - 12 lines]
> > > have got coding to work with a interger value but cannot get it to work with
> > > a string value. Thanks for any help.