Forms and List Boxes

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've got a listbox that uses a query to get a list of ID#'s, Names, and
Positions from a table; then displays it, with th stored value property set
to the ID#. Now what I would like to do is have a series of text boxes in the
form (that start out blank) be populated when a user clicks on one of the
items in the listbox. The information would come off the original table,
based on the ID# (stored value from the listbox).

My goal is to make an easy way for someone to select a specific user to view
the details of, make changes as needed. Or have a button to allow the user to
clear the fields, enter a new employee, and then save that new entry into the
table. If I can figure out how to pull the information off the table and into
the text boxes, based on the selection from the list box, I think I can
manage to work out the rest.

Thanks in advance for any help offered.
 
If you have all the textboxes on the form bound to the source tbl, and set
data entry to true you will have the blank boxes ready, leave the combobox
unbound and on the After_Update event of said combobox, set the data entry to
false and then set the recordsource to something like "SELECT * FROM
tblmyTable WHERE tblMyTableID = " & me.cboMyComboBox & "" or use extra ' '
around the me.cbo... part if the field is text rather than numerical.

TonyT..
 
If the textboxes are bound to the source table, the SELECT code I gave you,
will populate all the fields itself, providing you set dataentry to false
before setting recordsource.

TonyT..
 
I'm still getting problems. Here's the code for the click event of the listbox:

Private Sub fillBoxes()
Form_addEmployee2.DataEntry = False
Form_addEmployee2.RecordSource = "SELECT * FROM employeeList WHERE
employeeID = " & Me.List26 & ""
End Sub

I get the error:

Run-Time error '3058':
Index or primary key cannot contain Null Value

If I comment out the line setting DataEntry to false I get this error:

Run-Time error '2107':
The value you entered doesn't meet the validation rule defined for the field
control.

There's no validation rule for any textbox, or the list box. I set the
"Form_addEmployee2.DataEntry = True" line in the Form_Load() event.

Any thoughts what I'm messing up on? Thanks for all your help.

Rob
 
Looks like there is data in a field of the form and it's trying to save it
without the primary key having a value, try inserting;
If me.dirty then
me.undo
end if

before me.recordsource = "SELECT........

me. should do instead of fully referencing the formname, as the control is
on the form with the focus (ie the *me* form)

TonyT..
 
Thanks, that code seems to help with the errors. I am not getting another
error though.

Run-Time Error '3008':
The table 'employeeList' is already opened exclusively by another user, or
it is already open through the user interface and cannot be manipulated
programmatically.

It doesn't seem to like my altering the RecordSource value. I tried removing
all record locking, but it doesn't seem to help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top