Erasing text from textbox upon enter without deleting variable value

andyrew30

Registered User.
Local time
Today, 15:24
Joined
Feb 3, 2014
Messages
16
Hi Guys,

I have a quick question that I've spent a decent amount of time looking through google and other forums and still can't quite figure it out. Essentially I have a form that has a textbox in it. I enter text into the text box by scanning a bar code. I then use openreport.cmd to pass the variable in the text box to the report I generate. The report then has a button that when clicked references the variable that I passed to it. Essentially the problem I am having is that when I set the textbox back to blank, it also erases the contents of the new variable created. I want to either delete the value from the textbox upon scanning the bar code each time, or highlight the value in the textbox for it to be deleted upon the first key stroke. I had read about setting focus to the textbox, but I have been unable to get that to work. Here is my current code for what I am doing.

Code in the form:

stPartNum = Me.ScannerTxt

Label = stPartNum

DoCmd.OpenReport "RptLabels", acViewPreview, , , acWindowNormal, stPartNum

Code in report button:

partnum = Me.OpenArgs

Thanks!!
 
Is the textbox unbound, or what do you mean by "it also erases the contents of the new variable created"?
Where and when do you set the textbox back to blank?
 
The textbox is unbound. I set the textbox equal to a variable "stPartNum", then in the middle of the code I use "DoCmd.OpenReport "RptLabels", acViewPreview, , , acWindowNormal, stPartNum" to open the report, and at the end of the code I set "stPartNum" back to ""(blank). But when i use that method it stores ""(blank) in partnum in the report when attempting to use it in the report that calls "partnum = Me.OpenArgs"
 
Did you control if stPartNum has any value, just before you open the report?
Did you control if Me.OpenArgs (in report) has any value?
 
I'm not sure what I did, but it started working correctly...I think I was resetting the value back to blank to early.

Thanks for the help!
 
Okay - then everything is fine! :)
 

Users who are viewing this thread

Back
Top Bottom