I have stumbled into an interesting problem. Actually I stumbled into it last year and it has come back up once again. I didn't get the problem taken care of last year so it has been left over to deal with this year.
In my program when the person doing data entry, types in the bib number and hits the tab key the program is suppose to search the data file and make sure that no one else has the same bib. If the person doing the data entry mistyped or whatever and put the same bib number in twice the program is suppose to bring up a msgbox saying "Bib number already in use". Then its suppose to reset the focus back on the bib textbox so the correct bib can be reentered.
To this point everything runs smooth. It checks for the multiple bib, brings up the msgbox, if necessary, and then takes the user back to the bib textbox to retype in the bib number.
The problem comes when the user tabs off the bib the second time. The program doesn't perform like it's suppose to. Instead of sorting the bibs, if need be, and putting a blank row of textboxes below the ones most recently used, it sorts the bibs removes the top entry altogether and leaves two blank rows of textboxes at the bottom.
Now the odd twist'S'. If I use Debug to step through it, everything works fine. If I put in a secondary msgbox in the area around where it's searching for the multiple bibs, everything works fine. It acts like if I put a pause in the system everything works fine. If after putting in the initial wrong bib number I instead cursor up to one of the other bibs and tab off it and then come back down and enter the correct bib number and tab off it again than it works fine. It won't work fine I do it straight through without any kind of a 'pause'/interruption. Everything else works exactly the way it should. This one almost does. Below is the code in the area where I'm having it do the searching for the multiple bibs. Granted I don't think it will help any but you never know.
Code:
If lastentry > 0 Then 'check that bib number isn't already in use
If Textbib(index).Text <> "" Then
For i = 0 To lastentry
If Textbib(index) = bib(i) Then
MsgBox "Bib number already in use"
Textbib(index) = ""
Textbib(index).SetFocus
Exit Sub
End If
Next i
End If
End If
Last edited by meant2b; Feb 8th, 2010 at 10:44 PM.
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Private Sub Textbib_KeyPress(Index As Integer, KeyAscii As Integer)
Dim i As Integer
If KeyAscii = 9 And Not ShiftPressed Then
If Textname(Index).Text = "" Then ' ensure name is entered
Textname(Index).SetFocus
Exit Sub
End If
If Textclub(Index).Text = "" Then ' ensure club is entered
Textclub(Index).SetFocus
Exit Sub
End If
If Len(Textbib(Index).Text) = 1 Then Textbib(Index) = "0" & Textbib(Index) ' ensure two digit bib number or enter a leading "0"
If lastentry > 0 Then 'check that bib number isn't already in use
If Textbib(Index).Text <> "" Then
For i = 0 To lastentry
If Textbib(Index) = Bib(i) Then
MsgBox "Bib number already in use"
Textbib(Index) = ""
Textbib(Index).SetFocus
Exit Sub
End If
Next i
End If
End If
Below this point it checks to find out how many textbox rows are on the screen to decide if it needs to show another or if it needs to scroll the data up.
Other than this one particular situation the code works exactly like I want it to.
A suggestion:
For checking empty textboxes, check it's length....:
Code:
If len(Textname(Index).Text) = 0 Then
Because, if there is a space, then your checking condition won't be going to work...
If my post was helpful to you, then express your gratitude using Rate this Post.
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video) My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet Social Group:VBForums - Developers from India
Good point. I hadn't even though about that. At times I'm thinking multi users and at other times I'm thinking about me being the only person using the program.
I've found the same problem, mentioned in my previous posting, in another part of the program now. When creating the database which will be used to print off the registration bubble sheets, later, I have it check to make sure the same name isn't entered twice. It seems like the problem is the same as what I mentioned before. I'm totally stumped on the entire problem.
I've included all the necessary code that is running the program up to this point in the .zip file. Both text files should go in a folder C:\Jump Results. I have the program setup to automatically allow the user to create a new file just by hitting the ESC key or to choose which file they want to save to. Everything gets saved to a specific location that way there is no losing anything. The program also automatically saves the data so there is very little chance of losing any data(the computer this program has been used on in the past is known to turn itself off while you are typing). I decided not to take any chances as I started writing this a couple winters ago. Better safe than sorry.