473,372 Members | 1,094 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,372 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 3344
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
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.