Macro Action to Select a listbox item

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

Guest

I have a form that contains several combo boxes and a listbox. The listbox
is populated by a query that counts the number of entries in a table and
works fine. This number (ID number)is in turn used as an identifier for a
log of records. After all the fields are completed, I would like the user to
click a submit button (which runs my macro) that will append the info to a
table.

My problem is, in order for the ID number to be transfered using my append
query, it must be clicked on (black highlighted). Is there a way for my
macro to go in and "select" (ie. Highlight) the ID number (contained in a
listbox)? I have tried the select object action, but haven't had much luck.
Thx.

~Ryan
 
may i ask why you're using a listbox control? usually, the purpose of a
listbox or a combo box is to allow users to make a selection from a finite
list of possible data entries. but from your description, it sounds like 1)
there's only one value in the listbox, and 2) that value is predetermined as
the "correct" value and the user has no choice in the matter. if both these
points are correct, it might be easier to use a textbox control to hold the
value of the ID number, and set the textbox control's value using a DCount()
function.

hth
 
Tina,

Thank-you so much, you have helped me out a lot. Just getting back into
Access after a year and a half off. Forgot about DCount, works just for what
I need.

~Ryan
 
just right rather....

RyanRedpoint said:
Tina,

Thank-you so much, you have helped me out a lot. Just getting back into
Access after a year and a half off. Forgot about DCount, works just right for what
I need.

~Ryan
 
I now have a text box using the Dcount function, it would be nice if when I
ran my macro that I could "refresh" (re-execute) that data to increment my ID
number for the next entry. Right now I am doing so by closing the form and
opening it which works very quickly, however there must be a more elegant way
right?

To state things a little more clearly: Basically the form acts as a log to
enter problem information into, clicking the submit button runs a macro that
appends the data to a table and resets all the form fields to null for the
next entry. I'd like to add ability for the macro to update that text box
for the next entry (by some method other than opening and closing the form).
That way my form is ready for the next log entry. Can't really find any
"Actions" in the macro window that do what I want.

~Ryan
 
well, to update the textbox after the data has been appended, you can just
run the same code you used to update the textbox the "first" time. if you
have multiple users, though, and since you say that this value is an ID
based on the return value of the DCount() function, i wouldn't assign the
value until the Append query runs - even then, you still have the
possibility that two users will append a record at the same time, and thus
both will get the same return value from the DCount() function.

i also wonder why you don't just bind the destination table to the form,
rather than using an unbound form and an Append query and resetting unbound
controls to Null.

hth
 
Back
Top