I don't Excel at Access

F

Freddy

I have a simple Access database for tracking the location of 'books'
within an office. I would like to use a form to allow people to check
the books in and out and enable others to see where the books are
(Checked In to the 'library' or checked Out to a User). The form has: a
combo-box to list all of the books in the library, an unbound textbox
with a network user name function and control buttons for 'Check In'
and 'Check Out'. The problem is I don't know how to write the code for
the control buttons that will change the values (In/Out, username and
date) of the record selected in the combo-box.

I have the following code in the "OnClick" event of the 'Check In'
button:
Public Sub Inbtn_Click()
'get variables for Code, Date and User
Forms![tu tracking form]!Code.SetFocus
Let strCode = Forms![tu tracking form]!Code.Text
Forms![tu tracking form]!Date.SetFocus
Let strDate = Forms![tu tracking form]!Date.Text
Forms![tu tracking form]!User.SetFocus
Let strUser = Forms![tu tracking form]!User.Text
' Row in combo-box/table
Let strindex = Forms![tu tracking form]!Product.ListIndex
Let strRowNo = strindex + 1

.... and this is where I'm lost. I don't know how to to write the
values for the variables to the table. To use an Excel analogy, how do

you reference a specific "cell" (row (strRowNo) / field (User, Date,
In/Out) in the table?

I'm standing on the edge and I just need a little push (I think). Help

please.

Thanx,

Geoff
 
R

Rob Oldfield

I don't quite get what you're attempting to do: overwrite an existing record
or add a new one?
 
F

Freddy

Rob,
Thanks for your reply. I'm trying to overwrite (parts of) the record.
I would leave the ' Book Code' and 'Book Title' as is and overwrite the
values for 'In/Out', 'User' and 'Date'.
Thanx,
Geoff
 
R

Rob Oldfield

There are a few different ways to do it, but the one I'd go for would be to
use a bound form...

Create a form that's bound to your table (so each text box/control
corresponds to a column in Excel speak)
Add a combo onto it using the wizard, that will give you the option of it
looking up an existing record (i.e. will take you to the correct 'row').
You can look at the code it generates by seeing the combos afterupdate
event.

The code behind the button would then just need to be something like:

me.username=fosusername() 'or whatever your function is called
me.txtDate=date() 'having controls and fields called 'Date' is a bad idea
btw
me.InOut=not me.InOut

That last line is assuming that your InOut field is boolean (and so will
show as a check box). The idea of it is that it will change to true if
false, and vice versa.
 

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

Top