Speed Print Key (1 Viewer)

yeasir01

Registered User.
Local time
Today, 13:58
Joined
Mar 26, 2018
Messages
67
Hello,

I have a form I designed to be able to input data & print shelf tags quickly. An idea I had was add a quick-print toggle switch when switch on any barcode that's keyed in or scanned using a wedge scanner will change the [select] for that item from false to true.

I tried the following with no luck. Any help would be appreciated.

Code:
Dim strSql As String
    strSql = "Update MerchandiseTable Set [Select] = true" & "where upc = me.searchtext"
    CurrentDb.Execute strSql
 

Attachments

  • Shelf Tag Labels.accdb
    1.2 MB · Views: 234

June7

AWF VIP
Local time
Today, 12:58
Joined
Mar 9, 2014
Messages
5,496
Concatenation is incorrect.

strSql = "Update MerchandiseTable Set [Select] = true where upc = " & Me.searchtext

SELECT is a reserved word. Should not use reserved words as names for anything.
 

yeasir01

Registered User.
Local time
Today, 13:58
Joined
Mar 26, 2018
Messages
67
That didn't seem to work i recieved a run time error 3464.Good point on the reserved word, ill have to go back and change that to selected instead. Any other thoughts?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:58
Joined
May 7, 2009
Messages
19,246
strSql = "Update MerchandiseTable Set [Select] = true where upc = " & Chr(34) & me.searchtext & Chr(34)
 

isladogs

MVP / VIP
Local time
Today, 21:58
Joined
Jan 14, 2017
Messages
18,258
Just wondering. How is clicking a toggle button any faster than clicking a checkbox?
 

June7

AWF VIP
Local time
Today, 12:58
Joined
Mar 9, 2014
Messages
5,496
Yes, if upc is a text type field, use arnel's syntax or

strSql = "Update MerchandiseTable Set [Select] = true where upc = '" & me.searchtext & "'"
 

yeasir01

Registered User.
Local time
Today, 13:58
Joined
Mar 26, 2018
Messages
67
Just wondering. How is clicking a toggle button any faster than clicking a checkbox?

toggle method
scan, scan, scan to add three items to print list then print

Manual Tick Option
scan to search
tick checkbox
scan to seatch
tick checkbox

:)
 

yeasir01

Registered User.
Local time
Today, 13:58
Joined
Mar 26, 2018
Messages
67
I had to redesign the database to work for multi user. The flaw in my first design was the check box was bound & stored on table which was used for selecting items to print. I quikly relized that will not work when the tables are being shared. @CJ_london made a great suggestion https://www.access-programmers.co.uk/forums/showthread.php?t=289116 , to basically highlight a row & store the ID on an unbound text box on the main form for query actions & what not. Now my speed print button no longer works

Previous Code
Code:
Dim strSql As String
strSql = "Update MerchandiseTable Set [selected] = true where upc = " & Chr(34) & Me.SearchText & Chr(34)
CurrentDb.Execute strSql

CJ_Londin code for selecting & deselecting items
Code:
If InStr("|" & Forms("MainSearchForm").SelectedData, "|" & ID & "|") Then
       Forms("MainSearchForm").SelectedData = Replace(Forms("MainSearchForm").SelectedData, ID & "|", "")
    Else
       Forms("MainSearchForm").SelectedData = Forms("MainSearchForm").SelectedData & ID & "|"
    End If


Im having a hard time merging the two codes to make it work. What I need is a UPC lookup if there is a match then mark that record as selected.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 21:58
Joined
Feb 19, 2013
Messages
16,674
don't see why you need that code. If you have done what I suggested in the other thread, you would just need to run the report. The code you are showing is updating a table (which is what you wanted to stop doing due to being multiuser) I presume the next bit of your code (not shown) is to run the report - that's all you need
 

yeasir01

Registered User.
Local time
Today, 13:58
Joined
Mar 26, 2018
Messages
67
don't see why you need that code. If you have done what I suggested in the other thread, you would just need to run the report. The code you are showing is updating a table (which is what you wanted to stop doing due to being multiuser) I presume the next bit of your code (not shown) is to run the report - that's all you need

I actually added the speed key so I can scan a barcode and have that item put in a que for printing or displaying the report. Hope that makes sense. It speeds up the process of select only the items you would like to print.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 21:58
Joined
Feb 19, 2013
Messages
16,674
not sure which event you are using when you scan a barcode but sounds like you are only adding to the list, not deselecting so just use that part of the code. You don't need the sql

Code:
Forms("MainSearchForm").SelectedData = Forms("MainSearchForm").SelectedData & ID & "|"

leave the other code as it is so you can deselect it if required
 

yeasir01

Registered User.
Local time
Today, 13:58
Joined
Mar 26, 2018
Messages
67
not sure which event you are using when you scan a barcode but sounds like you are only adding to the list, not deselecting so just use that part of the code. You don't need the sql

Code:
Forms("MainSearchForm").SelectedData = Forms("MainSearchForm").SelectedData & ID & "|"

leave the other code as it is so you can deselect it if required

I attached a picture to hopfully convey the message a little better.
 

Attachments

  • Example.png
    Example.png
    22.6 KB · Views: 198

yeasir01

Registered User.
Local time
Today, 13:58
Joined
Mar 26, 2018
Messages
67
Heres what I came up with, Is this the best way to do this?

Code:
Forms("MainSearchForm").SelectedData = dlookup("id","merchandisetable", searchtext) & "|"
 

CJ_London

Super Moderator
Staff member
Local time
Today, 21:58
Joined
Feb 19, 2013
Messages
16,674
sorry, no idea and I don't see the relevance of the image you provided
 

yeasir01

Registered User.
Local time
Today, 13:58
Joined
Mar 26, 2018
Messages
67
For anyone doing the a similar project here's the syntax that worked for me. The one posted before this one did not work.

Code:
if Me.SpeedScan = True And DCount("UPC", "merchandisetable", "UPC=" & "Forms!MainSearchForm!searchtext") = 1 Then
Me.SelectedData = Me.SelectedData & DLookup("ID", "merchandisetable", "UPC=" & "Forms!MainSearchForm!searchtext") & "|"

Im not sure if it is the most effiecient, but it certainly works.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:58
Joined
May 7, 2009
Messages
19,246
you can further reduced your code:
Code:
if Me.SpeedScan = True Then _
Me.SelectedData = Me.SelectedData & (DLookup("ID", "merchandisetable", "UPC=" & "Forms!MainSearchForm!searchtext") + "|")
 

Users who are viewing this thread

Top Bottom