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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB deletes value in textbox during run time

Status
Not open for further replies.

plarsen

Programmer
Jul 30, 2002
27
DK
Hi

I have a button on my form and then the code from that button runs, without stepping through the code, it deletes the value of the txtRunnerNumber textbox that has been inserted by the code earlier on.

Why does the code deletes the value and not then i stepping through the code?

My code for the button is as follows:

Dim team, club As String
If Combo1.Visible = True Then
team = Combo1.Text
club = txtRunnerClub.Text
End If
If Check1 = 0 Then
Me.Data1.Recordset.AddNew
Check1 = 1
Else
Me.Data1.Recordset.Update
Me.Data1.Recordset.AddNew
End If
If Combo1.Visible = True Then
Combo1.Text = team
txtRunnerClub.Text = club
End If
Me.Data3.RecordSource = "SELECT RunnerNumber, Used FROM tblChips WHERE Used = 0"
Me.Data3.Refresh
Me.txtRunnerNumber.Text = Me.Data3.Recordset.Fields(0)
Me.Data3.Recordset.Edit
Me.Data3.Recordset.Fields(1) = True
Me.Data3.Recordset.Update
Me.txtRunnerNumber.SetFocus


/Peter
 
Does it delete the value?

Or does it assign the value before the record loads?

Try adding a Pause, or a timer before setting the value...

Or see if there is a way to check if the data is loaded (such as turning off an async property, or checking a status property...)

Maybe even something like:
Me.Data3.Refresh
Do: doevents: loop until Me.Data3.Recordset.Fields(0) <> ""
Me.txtRunnerNumber.Text = Me.Data3.Recordset.Fields(0)

(But ONLY if you can guarantee that the field will ALWAYS be non blank)...

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 

Is your recordset loading in async mode? If so then this can happen, however I think with the exact code you have posted, the following code would error out when referenced to earlier.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top