Run-Time Error 3331

hhzyousafi

Registered User.
Local time
Today, 19:50
Joined
Nov 18, 2013
Messages
74
I have a form that has a SQL query with a JOIN of two tables as the recordsource. I have one unbound field, a dropdown, on the form and one bound field, a text box, and both of these fields have to do with the TaskID. The JOIN of two tables is as per the TaskID. Now if I pass a "TaskID" to the bound field at the time the form loads the fields on the form filter exactly as intended and show me the data relevant to that particular TaskID; however when I select the TaskID from the unbound field and pass that selection to the bound field I get a run-time error.

I have completely redesigned and restructured my form and I am still getting this error. What have I done wrong?
 
are you taking into account that a combobox is a zero based array?
I.e. the first column is column 0 not 1
 
I honestly have no idea what that means. I am using something like this:

BoundField.Value = UnboundField.Value

The unbound field is a combo box and the bound field is a text box.
 
I suggest you post a copy of your database. Also you could tell us something about the purpose of the application, since all you have mentioned is details of a form.

What should readers be looking for?
Can you provide a scenario with some data to indicate what you expect to happen?
 
Hi jdraw,

Well I have two main tables I am pretty much doing everything with. One table is called tblTasks and the other is called tblTaskHistory. The first table, tblTasks, has a one to many relationship to the other table, tblTaskHistory, via the "TaskID" field. The end-user comes to this form, lets call this form frmTaskHistory, and he/she can select his/her tasks from the unbound combo box that shows the values in the "TaskID" field for his/her tasks. Once the end-user selects a value from the unbound combo box the form has fields from the tblTasks table that refreshes and shows values in those fields related to the "TaskID" the end-user selected. The exact code I am using for this in the unbound combo box's "After Update" property is as follows:

BoundField.Value = BoundField.DefaultValue
BoundField.Value = UnboundField.Value

Access keeps highlighting these two lines of code when I press "Debug". I know the value is passing just fine as I can show the value in a message box; however for some reason the value is not passing into the BoundField. I hope that helps. If that doesn't let me see what I can do to get you a copy of the DB.

Regards,

Zohair Yousafi
 
Hi namliam,

I read through that post but the information in the post wasn't able to help.

Regards,

Zohair Yousafi
 
you probably cannot just set the bound field to a particular value. that will have the effect of changing the value for the selected record, rather than navigate to a different record

you probably need to do something like

- set the focus to the bound control
- run code to find the required required -

this will move the active record to one you require

try docmd.findrecord etc
 
Okay so after playing around with this I haven't been able to solve the issue; however I think I have been able to "debug" and get more information. I have code executing when the form loads and that code as the following line:

DoCmd.GoToRecord , , acNewRec

When I comment out this line of code the code in the previous posts works exactly as intended. The problem is that the form is not recognizing a record event exists as the first field the user selects is unbound and therefore it doesn't filter anything based on that. Does that mean I need to do an INSERT query or something like that?
 
I wasn't able to resolve this in the true meaning of the word; however I worked around this. I created a bound form to one of the two tables and then ran this code and it worked like a charm. I didn't want to have a form bound on a particular table; however I guess I will have to live with it :)
 

Users who are viewing this thread

Back
Top Bottom