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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access Page, storing data value in field from drop down list

Status
Not open for further replies.

Theroc

Technical User
Mar 17, 2006
2
US
I'm doing some volunteer work for a charity and have become stuck on what I know is a simple problem.

I have created several web access pages for data entry. One of the fields on one page is the primary key for a second table. To make sure the data was entered correctly I created a drop down menu with the values from the second table. When creating a new entry I can't get the data value from the drop down list to store into the field. The error I get is:

The field ClassesData:program Name contains a Null Value etc...

The drop down box is showing the data I want to store, I just don't know how to link it to the given field. I'm sure the answer is simple but this is my first time playing around with Web Access Pages so help is much appreciated.
 
You have a control that's a dropdown with values from table two that when selected will become a primary key in table 2?????? I don't think so. You'll get duplicate primary keys and that's a huge no-no. In fact, it won't let you. Or do you have two different columns with the same data??

When you clear that up, it save data, try this:
In design view, right click your mouse, select Microsoft Script Editor. On the left, you should see Script Outline. Scroll down to the combobox name, double click to expand it. Scroll down to onchange and double click on it. In the right pane you should see <Script and below it </Script. In between you can put something like this:(sSQL is all on one line)

dim sSQL
sSQL = "INSERT INTO TableName (TableFieldName) VALUES ('" & CSTR(ControlName.value) & "')"
MSODSC.Connection.Execute sSQL

'" & CINT(controlname.value) & "' if numeric




 
First off the primary key is in another table, and supplies a drop down menu for choices in the table I'm talking about editing. It is not a primary key in the talbe I'm editing.

Secondly I tried following your advice, but couldn't get past double clicking, nothing happens at that point. If your assuming it brought up the properties bar at that point, which I already had displayed, then there is no field labeled "onchange" or something similiar.

I probably should of stated in the initial post that it is office 2003 I am using if that changes anything.
 
Misread your post. You want to store the field in the first table.
Let's take this a step at a time so I can follow you.
In design view, did you right click your mouse and get the menu with Microsoft Script Editor?
In Script Editor, on the left, do you see the pane Script Outline? Do you see Client Objects and Events? If you do, expand it and you should see your control names. Scroll down to your combobox name and it should have a + sign next to it. If you expand that, you should see the "onchange" event. If you double click on that, in the right pane you should see the script section.

In 2003, it should still look something like that. Unfortunately I have 2000 and don't have access to 2003. You might have to look around or right click on script or something.

Which step looks different?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top