From Form Header to Form Detail to Table Field

gucci

Registered User.
Local time
Today, 09:04
Joined
Mar 24, 2007
Messages
42
I have a Undound combo box in the form header. The form is set to a Continuous Form and each continuation of the form needs to store the selected value of the header conbo box. So I put a hidden textbox in the detail section to capture the combo box selected value. And it does but I want this value to be entered into a field in the table. How do I do this.

Thanks again.
 
set the 'Control Source' property of that field to the field in the table you want it stored in.
 
I think you don't need a combo box in the form header.
Put combo box in the textbox, make this textbox unhidden,
and link them with the field in the table.
 
set the 'Control Source' property of that field to the field in the table you want it stored in.

You mean set the control source of the hidden text box to the field in the table I want it stored in.

OK if I do that what code do I entry in the afterupdate to capture the selected value from the header's combo box and store it in the tables field.

Thanks
 
I think you don't need a combo box in the form header.
Put combo box in the textbox, make this textbox unhidden,
and link them with the field in the table.

Do you mean change the hidden text box to a unhidden combo box and have no combo box in the header. If I did this then I would have to select a value for every continuation of the form and this is what I'm trying to avoid. Unless I' not understanding you solution.

Thanks
 
Hello gucci!

I say you don't need a combo in the header,
Look at "DemoComboValueA2000.mdb".
Open frmOrder and try.
 

Attachments

I have looked at this and I see what you are trying to get me todo. But I have 3 of these combo boxes and once I select an entry it is the same for all the next entries. With what you are doing is different.
 
What about code like this. I go it from another DB but not sure if it would work.

Sub Combo1_AfterUpdate()

Dim db as DAO.Database, sSQL as String

Set db = CurrentDb
DoCmd.SetWarnings False

sSQL = "UPDATE tblYourTable SET Col1 = '" & Me.Combo1 & "';"
db.Execute sSQL
DoCmd.SetWarnings True

End Sub

I tried it but it would not work right...

Any ideas.
 
Define "not work right".
 
I was told to make sure that I had the right table and right col and I have.
Then to have reference to MS DAO selected in Tools / References in the design mode. What I have selected and I did that but I still get a error:
Run-time error '3061':
Too Few Parameters. Expected 1.
And when I click debug the following is highlighted in yellow;
db.Execute sSQL

So it does not work and I do not know why.
My table is: Invoice
Table column is: 4
Combo Box is: OurCompanyID

Thanks for the help.
 
If the data type of the field is numeric, you don't want the single quotes around the value. I would expect a type mismatch error, but check it out.
 
It is numeric but I did remember to remove the single quotes.
I put my original Tools/Reference back to default.

They are Visual Basic Applications
Microsoft 12.0 Object Libary
OLE Automation
Microsoft Office 12.0 Access DB engine Object

These are the DAO options not selected.
Microsoft DAO 2.51/3.51 Compatibitity Libary
Microsoft DAO 3.51 Object Libary
Microsoft DAO 3.6 Object Libary

So what should I have selected. So far I get the same error. And if I want to select any of the DAO options I have to deselect "Microsoft Office 12.0 Access DB engine Object"

Thanks
 
Is this the code you want or do you want me to upload the full DB.

Private Sub OurCompanyID_AfterUpdate()

Dim db As DAO.Database, sSQL As String

Set db = CurrentDb
DoCmd.SetWarnings False

sSQL = "UPDATE Invoice SET Col4 = " & Me.OurCompanyID & " ;"
db.Execute sSQL
DoCmd.SetWarnings True

End Sub
 
Col4 should be the actual name of the field in the table. Also, you don't need the 2 SetWarnings lines.
 
OK I did that and it stop the 3061 error but it still does not enter the info into fields. And can I just delete the two setwarnings lines.
do I need to enter which column of the combo box is entered.
 
I guess it would be easier if you upload a sample. Yes, you can delete both lines. The Execute method does not generate the warning messages.
 
OK I'll upload it. What version of Access are you using. And I noticed some thing very strange. If I use the form to enter 2 rows of data the combo box entries are not entered. Then I open the form and enter two more rows of data and look at the table again. And the combo box values for the second 2 rows of data are in the first 2 rows of data. What's the problem there.
 
Here it is. The form I need you to look at is VATReturn.
Thanks
 

Attachments

Users who are viewing this thread

Back
Top Bottom