assigning text. (1 Viewer)

chucky

New member
Local time
Today, 15:23
Joined
Apr 23, 2002
Messages
7
I am trying to assign text to field in the main form. but can't get it to work. I have tried the following. the these error occur.

A)
Forms!FMSServerDetails11!EffortH.Value=effort

run time error "2448":
you can not assign a value to this object.


B)
Forms!FMSServerDetails11!EffortH.Text=effort

run time error "2185":
You cant referense a property or method for a control unless the control has the focus.

C)
Forms!FMSServerDetails11!EffortH.SetFocus
Forms!FMSServerDetails11!EffortH.Text=effort

cannot assign the focus to this control

Can any one help. C does work some of the time though
 

Travis

Registered User.
Local time
Today, 07:23
Joined
Dec 17, 1999
Messages
1,332
Try this

Forms!FMSServerDetails11!EffortH

or

Forms!FMSServerDetails11.EffortH

Value/Text do not work the same as Visual Basic.

Remember it is best to use the "!" when referencing a field and "." when referencing a control/property
 

chucky

New member
Local time
Today, 15:23
Joined
Apr 23, 2002
Messages
7
so instead of using text/value just use the field name when getting or assigning text to and from the fields
 

boblarson

Smeghead
Local time
Today, 07:23
Joined
Jan 12, 2001
Messages
32,059
Actually using .Value DOES work and I use it all the time for clarity's sake in my code (for our not-so-advanced people).

First of all, make sure that the textbox is NOT named the same as your field name. That'll help immensely.

I have a question for you. Are you trying to assign the word "effort" to this textbox or is effort a variable? If you are trying to assign the actual text "effort" to this textbox then you would need to do either:

Forms!FMSServerDetails11!EffortH.Value = "effort"

or

Forms!FMSServerDetails11!EffortH = "effort"

(assuming that EffortH is not your table's field name)

If it is, then rename the text box something like txtEffortH and then do:


Forms!FMSServerDetails11!txtEffortH.Value = "effort"

or

Forms!FMSServerDetails11!txtEffortH = "effort"


Should work then.

BL
hth
 

chucky

New member
Local time
Today, 15:23
Joined
Apr 23, 2002
Messages
7
ok effort is a variable that i am using. Thanks for that about the field name and text box. I thibk i do have a few that clash. I will go and fix them up.

thanks for the help.
 

chucky

New member
Local time
Today, 15:23
Joined
Apr 23, 2002
Messages
7
ok if i use forms![form]![field] = effort
to put data into the table do i then have to go and also update the form as well with

forms![form]![txtfield] = effort.

If i should happen why does it not happen. for my form to update i have to close it and then open it again.
 

boblarson

Smeghead
Local time
Today, 07:23
Joined
Jan 12, 2001
Messages
32,059
If you want to see the results of your change, you should be able to add this to the same event that you're using to do the changes your form (could be in the textbox's After Update event).

Me.Requery

BL
hth
 

chucky

New member
Local time
Today, 15:23
Joined
Apr 23, 2002
Messages
7
So putting me.requery in the after update of a text box will reset all the fields on the foorm or just the field that it is put in?
 

boblarson

Smeghead
Local time
Today, 07:23
Joined
Jan 12, 2001
Messages
32,059
What Me.Requery will do, is to update all of the fields on the form based on the record that is open at the time that you do it. In other words, it will make all changes visible and still stay at the same record you were at when you had it requery.

I hope that explains it. You may have to experiment with some of the different events to see exactly where to put it so that it meets your needs.

I hope that helps. My brain is not working all that well this morning and I'm not sure I explained it all that well.

BL
 

Users who are viewing this thread

Top Bottom