Snuggle Walrus
Member
- Local time
- Today, 23:50
- Joined
- May 14, 2020
- Messages
- 32
Hey everyone,
I'm trying to set up a lookup on a table that logs some serial numbers for a little side project of mine. I log the serial numbers of items into a table called tbl_serialnumbers. However, I've been implementing the option of allowing Part Numbers to be used when a serial doesn't exist. I realise this may seem odd... but obviously some scenarios have unique values in my Serial number field and others would have potential duplicate data as multiple MPN fields can exist.
In scenarios when I'm working with unique values my Dlookup looks like...
Here SerialIDScanSearch is my variable for the primary Key (unique value in the table) and my lookup is searching for Serial ID (unique value) from within the serial numbers table where the Serial Number field matches the scanned serial number in my text box. This has been working great! However, for the next part of my project, I'm trying to find a way of having it pull a SerialID (unique value) for an item that may have been booked in with an MPN. Appreciate this is tricky so the easiest way is doing a first in first out so the 'earliest' scan of this product that's currently not in use. For this, I was planning on adding to the criteria for OrderID = Null but I admit I'm unsure of the correct syntax for this or if this even works, I imagine I'd be changing the DLookup to a DMin? where I'm looking for the 'smallest' SerialID that matches the Scan but also doesn't currently have an orderID against it (this would still be a Null value within the table it holds no data until this point when I then run an update query via currentDb.execute.
I know there are a few ways within access to work with Null values but I'm unsure which applies when using this type of formula, all my coding knowledge is from self-taught trial and error and the pleasure of browsing this forum (thanks to everyone you've been an inspiration for nerdy little projects for the last 3 years). I believe something like the following could be used.
So these are my current two ideas for the lookup to try and return the smallest unique serial ID that still matches the part number scan BUT doesn't currently have an order ID assigned to it. I hope this all makes sense with what I'm trying to do. Thanks have a great day! Happy to answer any questions if I've not explained it well enough.
I'm trying to set up a lookup on a table that logs some serial numbers for a little side project of mine. I log the serial numbers of items into a table called tbl_serialnumbers. However, I've been implementing the option of allowing Part Numbers to be used when a serial doesn't exist. I realise this may seem odd... but obviously some scenarios have unique values in my Serial number field and others would have potential duplicate data as multiple MPN fields can exist.
In scenarios when I'm working with unique values my Dlookup looks like...
Code:
SerialIDScanSearch = DLookup("[SerialID]", "[tbl_SerialNumbers]", "[Serial Number]= '" & SerialScan & "'")
Here SerialIDScanSearch is my variable for the primary Key (unique value in the table) and my lookup is searching for Serial ID (unique value) from within the serial numbers table where the Serial Number field matches the scanned serial number in my text box. This has been working great! However, for the next part of my project, I'm trying to find a way of having it pull a SerialID (unique value) for an item that may have been booked in with an MPN. Appreciate this is tricky so the easiest way is doing a first in first out so the 'earliest' scan of this product that's currently not in use. For this, I was planning on adding to the criteria for OrderID = Null but I admit I'm unsure of the correct syntax for this or if this even works, I imagine I'd be changing the DLookup to a DMin? where I'm looking for the 'smallest' SerialID that matches the Scan but also doesn't currently have an orderID against it (this would still be a Null value within the table it holds no data until this point when I then run an update query via currentDb.execute.
I know there are a few ways within access to work with Null values but I'm unsure which applies when using this type of formula, all my coding knowledge is from self-taught trial and error and the pleasure of browsing this forum (thanks to everyone you've been an inspiration for nerdy little projects for the last 3 years). I believe something like the following could be used.
Code:
SerialIDScanSearch = DMin("[SerialID]", "[tbl_SerialNumbers]", "[Serial Number]=" & SerialID & " AND [OrderID]= Null)
Code:
SerialIDScanSearch = DMin("[SerialID]", "[tbl_SerialNumbers]", "[Serial Number]=" & SerialID & " AND IsNull([OrderID]))
So these are my current two ideas for the lookup to try and return the smallest unique serial ID that still matches the part number scan BUT doesn't currently have an order ID assigned to it. I hope this all makes sense with what I'm trying to do. Thanks have a great day! Happy to answer any questions if I've not explained it well enough.