468,790 Members | 1,853 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,790 developers. It's quick & easy.

Configuring Check Out Button To Update Field Value of another table

I will try to explain this to the best I can.

Currently, I am creating an asset inventory system. In the system, I have 2 tables (IT Assets and Contacts) and 3 separate forms (AssetEntry-F, AssetChecking-F, and Employee-F). I am in the process of creating the AssetChecking-F form, that will serve the purpose of checking in and checking out the asset once it is scanned via barcode. On the form, I have a text box, in which the user will scan the barcode on the item, and then either click the button for check in (which will populate a date and change the status of "In Stock" field on the IT Assets Table to true) or click the check out button (which will prompt the user for the first and last name of the user via InputBox, set the timestamp of check out, and change the "In Stock" field status to False.

The problem that I'm having (with the Check-Out button) is how to set the variables that I have created for grabbing the First & Last Name to update the fields (First Name, Last Name) on the Contacts Table since the AssetChecking-F form has the record source set for "IT Assets". Here is an example of my VBA code in progress (I am open to all feedback)
Expand|Select|Wrap|Line Numbers
  1. Private Sub AssetOut_Click()
  2.  
  3. Dim getOwnerFirst As String
  4. Dim getOwnerLast As String
  5.  
  6. getOwnerFirst = InputBox("Please associate the device with an owner. Enter the owner's first name", [Get Owner - First Name])
  7. getOwnerLast = InputBox("Please enter the owner's last name", [Get Owner Last Name])
  8.  
  9. If getOwnerFirst = “” Or IsNull(getOwnerFirst) Then
  10.  
  11.            ‘do Nothing
  12.  
  13.        Else
  14.  
  15. If getOwnerLast = “” Or IsNull(getOwnerLast) Then
  16.  
  17.            ‘do Nothing
  18.  
  19.        Else
  20.  
  21. Me.TimeOut = Date
  22.  
  23. Me.[In Stock] = False
  24.  
  25. End Sub
4 Weeks Ago #1
1 3019
NeoPa
32,132 Expert Mod 16PB
One easy fix is never to use a word processor to work with code. They typically update actual quote characters (' & ") to the ones used in letters or emails and shown in your code (“, ” & ‘) which just don't work as expected or required.

That's one of the reasons why we insist on posts including the [CODE] tags when code is used. That font shows up such errors quickly & obviously whereas the standard text font obscures the differences.

HicksMk2:
The problem that I'm having (with the Check-Out button) is how to set the variables that I have created for grabbing the First & Last Name to update the fields (First Name, Last Name) on the Contacts Table since the AssetChecking-F form has the record source set for "IT Assets".
The problem I'm having is that you haven't introduced or explained what these variables are nor what you're trying to do with them before referring to them in your explanation. I love that you're explaining the best that you can, but unfortunately I still need it to make sense if I'm to understand what you're doing & what might be going wrong.

Typically, and I'm guessing here by reading between the lines a bit, if you want to associate two records with each other, and like all good & helpful developers you want to do it in a way that makes it as easy as possible, and as reliable as possible, for your users, then you use a reference ID in one table that matches a reference ID in another.

Now, we know that users (Human thingies.) tend to struggle with reference IDs because their brains are taught to deal with names rather than such things. So, what we typically do is present to them a list of items that show names (In a ComboBox or ListBox Control on the Form.) but also have reference ID data associated with each row so that the code can reference the reference ID once the user has selected the name.

This approach is less open to users being unable to spell very well, or even type without hitting the wrong keys. In real life this is very important as they tend to do this quite a lot.
4 Weeks Ago #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Chris Nighswonger | last post: by
1 post views Thread by Tony Johnson | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
2 posts views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.