473,327 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

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
Jul 1 '21 #1

✓ answered by NeoPa

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.

1 3343
NeoPa
32,556 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.
Jul 1 '21 #2

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

Similar topics

0
by: Chris Nighswonger | last post by:
------=_NextPart_000_0013_01C352C0.6B0A6E30 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi All, Is it possible in MySQL to use UPDATE to update...
1
by: Tony Johnson | last post by:
I want to update a particular field in a form for only a certain set of records. The certain set of records is named Financed. I need to update those Financed records with a financed number that...
6
by: KevinPreston | last post by:
Hello everyone, this is my first post so apologies if i dont get it right first time, i am a self taught Access user, i am stuck on something i am trying to do, briefly i have 2 tables, one for...
4
rajiv07
by: rajiv07 | last post by:
Hi to all I want to know How to update null value in table. Is any idea please. Thanks Regards RajivGandhi
4
by: BulbFresh | last post by:
Hi, I'm using Access 2007. I have imported a table called 'January' and from this I need to update an existing table called 'TablesInfo' which needs to hold some details about the imported...
2
by: Hillwalker | last post by:
Hi Raw recruit, no VB knowledge but some general programming experience..... Access 2000 on XP In form view, I wish to fill the field (ONLY on the record being viewed) with the maximum value...
0
by: John Bloor | last post by:
I have a Microsoft Access 2007 database that uses a form whose recordset is a products table that contains an attachment field. From that form, I need to be able to append the current record to...
1
by: Ryno Bower | last post by:
Hi I am trying to update a field in one table by the total sum value of a field in another table. This value is in currency format. I get error messages when trying to use e.g. Amount =...
2
by: stormtrupr | last post by:
I have a Table(PA Phrases) consisting of phrases to be used in a purchase agreement, but not all phrases apply for every purchase agreement. I want to allow the sales rep to select the phrases...
4
by: moonrb | last post by:
I have two table named 'stock' & 'delivery' with following fields- stock- 1.product id 2.date 3.quantity delivery 1.memo no 2.product id
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.