Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TextBox Question 1

Status
Not open for further replies.

ITheadache

IS-IT--Management
Jun 13, 2006
45
US
I am trying to use a text box, and assign that value entered into the textbox to me.fieldname when a button is pressed. Unfortuneatly access keeps saying that an error has occured when I just say

me.fieldsname = textboxname

What do I need to do to fix this problem?

Thanks
 
ITheadache,
Make sure there is not a control with the same name as a field in the recordset? This is the defualt setting when you create a from using the wizard or drag a filed onto the form, and in my opinion creates nothing but headaches.

Alternatives:
[tt]Me.Recordset.Fields("fieldsname") = Me.textboxname[/tt]

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 

Me.Recordset.Fields("PFO2008") = Me.P2008
DoCmd.Close acForm, "DeviceSelection"

I tried to use the following code. p2008 is the textboxes name, and the pfo2008 is the field name. The error that was given to me was

'update or cancelupdate without addnew or edit'

What this is trying to do is pop up a form that askes for the data, and then after clicking the button writes the data in the text box to the field.

(because of add ons, using a form is the best way to go, and input boxes will not work for me in this case.)
 
ITheadache,
Is your popup form set to Data Entry? This will ensure that the form opens to a new record.

CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
Actually, no, I don't want it to open to a new record, I want it to edit the record I just created. I have a main form that has a new order button. The new order button will creat the new entry, and then I want it to pop up a new form, have the user enter in the quantity into textbox for each product, and then hit submit. This will then set the record of the new invoice with the number of each product sold in that sale.
 
ITheadache,
It almost sounds like the new record hasn't been saved before you spawn the new form.

CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
Yeah, I think that seems like the problem, but I can't figure out how to save it properly. Because even if I manually save the form, then open the new form, it still will not go to the new record. it only will if I either exit the form and reopen it, or create another new record, then it will go to the first new record.

Sorry for all the questions, I am new at this and trying to add onto an old employees program.
 
ITheadache,
Try [tt]Me.Recordset.Update[/tt] before you open the popup form. If that doesn't work you can use [tt]DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70[/tt].

CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
Thank you for your help.

The me.requery before loading the new form did the trick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top