Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Value will not clear from a textbox

Status
Not open for further replies.

autoIT

IS-IT--Management
May 10, 2006
68
US
I have a form that works as so:

There is a field for user input. This TextBox has an inout mask in it.

The next tabstop is another textbox that is transparent and when focus is set on it will retrieve info from a table based on what the user has input.

At the end of all this is a button that calls a private sub that send the info gathered to a seperate table and clears all textboxes to set the user up for the next entry.

The textboxes all clear but when the user inputs in the textbox with the input mask and tabs the value they enters changes to what was in there in the previous record.

The only other thing is, before the information is entered into the table, it is passed into a variable dimmed as a string first. The column value in the table is set to text as well. The input mask allows only numbers.


Why does the value continue to revert to the previous value, even if the textbox clears?

Adam
 

Have you tried setting the variable to "" when you clear the text boxes?


Randy
 
thought about that and tried it but for some reason doesnt clear the value. Do you clear a variable with an input mask with "" or is there something else? Also is there a clear screen method?
 
here's the code that checks the value entered against the table. This done when the "transparent" textbox receives focus. that's all this textbox is for:

Private Sub txtGetDealerinfo_GotFocus()


txtDealerCode.SetFocus
If txtDealerCode.Text <> "" Then
Do Until dealers.EOF = True
DealerCode = txtDealerCode.Text
If DealerCode = dealers.Fields.Item("Dealer Code") Then
Dealer = dealers.Fields.Item("Dealer")
dealers.MoveLast
Else
dealers.MoveNext
End If
Loop
txtDealerCode.SetFocus
txtDealerCode.Text = DealerCode
txtDealer.SetFocus
txtDealer.Text = Dealer
txtSubmittedBy.SetFocus
ElseIf txtDealerCode.Text = "" Then
txtSubmittedBy.SetFocus

End If
End Sub

here's the code that sends the gathered info to a table. Variable are dimmed at beginning of code under public declarations:

Private Sub SendInfo()

rs.AddNew

txtDesc.SetFocus
Desc = txtDesc.Text
rs.Fields.Item("Description") = UCase(Desc)
txtVinKey.SetFocus
VinKey = txtVinKey.Text
rs.Fields.Item("Vin Key") = UCase(VinKey)
txtColor.SetFocus
Color = txtColor.Text
rs.Fields.Item("Color") = UCase(Color)
txtDealer.SetFocus
Dealer = txtDealer.Text
rs.Fields.Item("Dealer") = UCase(Dealer)
txtDealerCode.SetFocus
DealerCode = txtDealerCode.Text
rs.Fields.Item("Dealer Code") = DealerCode
txtSubmittedBy.SetFocus
SubmittedBy = txtSubmittedBy.Text
rs.Fields.Item("Submitted By") = UCase(SubmittedBy)
txtBidAmount.SetFocus
Bid = txtBidAmount.Text
rs.Fields.Item("Bid Amount") = Bid


rs.UpdateBatch


End Sub


and finally the code for the button that triggers the information to be set, and comes back to clear all textboxes. setting dealercode variable to "" only clears the textbox the next time user inputs the dealercode only reverting back to the precious value anyway. here's the thing when the db is closed and reopend the value resets:

Private Sub btnEnterBid_Click()

SendInfo

txtVinKey.SetFocus
txtVinKey.Text = ""
txtModelCode.SetFocus
txtModelCode.Text = ""
txtDesc.SetFocus
txtDesc.Text = ""
txtColor.SetFocus
txtColor.Text = ""
txtDealerCode.SetFocus
txtDealerCode.Text = ""
txtDealer.SetFocus
txtDealer.Text = ""
txtSubmittedBy.SetFocus
txtSubmittedBy.Text = ""
txtBidAmount.SetFocus
txtBidAmount.Text = ""


'DealerCode = ""
txtVinKey.SetFocus
 
if you wont write the .text just text1 = "" you wont need the set focus at all somthing like this

Code:
txtVinKey = ""
txtModelCode = ""
txtDesc = ""
txtColor = ""
txtDealerCode = ""
txtDealer = ""
txtSubmittedBy = ""
txtBidAmount = ""


I will try my best to help others so will others do!!!!!
IGPCS
Brooklyn, NY
 
did noot know that. that is interestin let me give it a try
 
I think your problem might all go back to something very basic:

The next tabstop is another textbox that is transparent and when focus is set on it will retrieve info from a table based on what the user has input.

First of all, a text box has no transparent property; only command buttons do. If by transparent you mean you cannot actually see the text box on the form, you've set its Visible Property to No, and the problem with this is that when Visible is set to No, a text box cannot recieve focus so all your code depending on this is not being carried out! Change the text box back to Visible = Yes, then shrink it down in size until it's just a pinpoint. You might also want to move it somewhere on the form where the eye doesn't track, such as in a corner or up against a lable.

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
igpcs,

i wanted to thank you for your help, and for the .setfocus advice. I think you just cut my code in half. Second, I found my mistake. I was assigning the dealercode twice and it kept assigning the last one input:

Private Sub txtGetDealerinfo_GotFocus()


If txtDealerCode <> "" Then
Do Until dealers.EOF = True
DealerCode = txtDealerCode
If DealerCode = dealers.Fields.Item("Dealer Code") Then
Dealer = dealers.Fields.Item("Dealer")
dealers.MoveLast
Else
dealers.MoveNext
End If
Loop
txtDealerCode = DealerCode(***DIDNT NEED TO ASSIGN AGAIN***)
txtDealer = Dealer
txtSubmittedBy.SetFocus
ElseIf txtDealerCode.Text = "" Then
txtSubmittedBy.SetFocus
 
your welcome

I will try my best to help others so will others do!!!!!
IGPCS
Brooklyn, NY
 
one more question maybe you can answer:

I am using this line

CurrentDb.Execute "delete from BidQuery"

to clear a table and then I have code that queries another tabel to get specific information. It runs fine, populated the table I just cleared with the new information. I have code written in the same sequence that will goto table BidQuery to get the new information and populate textboxes with it but I get a run-time error record is deleted. The information is in the table but it's not seen for some reason. Is there a way to refresh the table so that the info that is there is seen.

Thanks again
adam
 
to elaborate the rows have been marked for deletion, and even though there is new information there, the rows are still marked for deletion. Do I need to close the connection to the table and reopen it?I attempted that and it's telling me that operation can't be used in that context.
 
me.refresh or me.requery

I will try my best to help others so will others do!!!!!
IGPCS
Brooklyn, NY
 
me being what. doesnt seem to work still marked for deletion. i used .requery b/c refresh not an option with adodb
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top