Using a form to update Access database records with visual basic code.

  • Thread starter Thread starter geoff.burkholder
  • Start date Start date
G

geoff.burkholder

As a new user to Access (and an old user of Excel), I'm having
difficulty getting my head around the whole
event/expression/macro/etc... setup in Access. 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
selecterd in the combo-box. Any help that can be offered will be
greatly appreciated. Thanx
 
Geoff,

You have to place code in the "OnClick" event of the button. In design
view, right click on the button and select "Properties". Click the "Events"
tab to see a list of all events for the button. Click once on the OnClick
line, then click the "..." to the right and select "Code Builder" from the
list. This will add the event to your code and open it for you to enter your
logic.

The code you enter will be executed each time the user clicks the button.

Note: if easier for you, you can select "Macro Builder" instead of "Code
Builder" and write a macro that runs when the button is clicked.

Bruce
 
Bruce,

Thanks for your repy. I had actually managed to get this far using
Code Builder:

Public Sub Inbtn_Click()
Forms![tu tracking form]!Code.SetFocus
Let strCode = Forms![tu tracking form]!Code.Text
If strCode = "" Then
MsgBox "Select a Product to Check In"
Forms![tu tracking form]!Product.SetFocus
Exit Sub
Else
MsgBox "Check In " & strCode & " ?"
End If
Forms![tu tracking form]!Date.SetFocus
Let strDate = Forms![tu tracking form]!Date.Text
Forms![tu tracking form]!Code.SetFocus
Let strCode = Forms![tu tracking form]!Code.Text
Forms![tu tracking form]!User.SetFocus
Let strUser = Forms![tu tracking form]!User.Text
Let strindex = Forms![tu tracking form]!Product.ListIndex
Let strRowNo = strindex + 1 ' Row in combo-box/table

.... 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
 

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