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

Blind Double Entry? 1

Status
Not open for further replies.

Lunatic

Technical User
May 8, 2006
405
0
0
US
I've found how to do the double entry in this thread:
thread702-1048332

But I'm having trouble looking through the forum for what I want to do, and that is I want to make it a blind double entry... I want code to visable while it is being entered but as soon as they go to the second box the first box becomes hidden/changed to astriks or something smiliar so they can't copy what they have just entered.

I've looked through the macros, expression builders and some of the properties but I'm not finding anything that would let me hide/obscure the data until both boxes match.

Thank you for any assistance or suggestions you can provide!
 
Have you tried settign an event 'onlostfocus' so that the visibility of the box is hidden once it is entered.

For the onlostfocus event procedure try-

Forms![Form Name].[Text box name].Visible = False

I'm sure it's just one way to skin the proverbial cat, but hope it helps!
 
Dibblet, Thanks! That worked great just not as a onlostfocus for the field... When I had it as an onlostfocus I recieved this error message:

Run-time error '2065'
You can't hide a control that has the focus

***

I ended up adding that code to the 2nd entry box as a GotFocus event procedure and then the changed it to true as a LostFocus event procedure.

So it hides everything wonderfully when I want it to and displays it when I want it to.

***

However I'm running into a new problem. I used the code from the thread I mentioned (modifed to fit my database):

If Me![Number Double Entry] <> Me![Number] Then
MsgBox "Numbers do not match please re-enter"
Me![Number Double Entry].SetFocus
Cancel = True
End If

The error message I receive states:

Run-time error '2108'
You must save the field before you execute the GoToControl action, the GoToControl method, or the SetFocus method

However, I don't want to save the record if its incorrect... I only want to save the record if bot the [Number Double Entry] and [Number] fields are equal...

One problem conquered, another reared!
 
Probably should let you all know...

[Number Double Entry] is the 1st box information is entered into
[Number] is the second box, and the important box

I added the GotFocus and LostFocus code to the [Number] box to hide/unhide the [Number Double Entry] box.

I wasn't as clear as I could be and I can't find an edit feature...
 
Hi, Lunatic,

Right. I presume you are using the BeforeUpdate event for your data validation. Essentially you are issuing two conflicting instructions. By setting Cancel to true, you telling Access "don't update the data I just entered" - but you are also trying to set the focus to a different control, which automatically updates the data in the current control.

To get around this, if the data fails your validation check in the BeforeUpdate event, use the .Undo method, don't set Cancel to true, then your SetFocus command should work properly.

HTH,

Ken S.
 
p.s. I haven't tested this, the SetFocus may not work right in the BeforeUpdate event - because obviously you can't set focus to another control before your data is updated. If it won't work, try the AfterUpdate event instead.

Ken S.
 
How are ya Lunatic . . .

I believe you need to [blue]rethink the logic of what you want to do here[/blue], as far as a [blue]proper[/blue] wrong double entry impact would have on your DB.

[purple]So . . . whats the fear? . . .[/purple]
[ol][li]A duplicate entry? . . . easily covered![/li]
[li]A non-duplicate entry that should'nt exist? . . . Hail validation! . . .[/li][/ol]
The problem is not correct double entry, [blue]its the impact the proper double entry will have on your DB[/blue] . . . [purple]and you've yet to explain what that is![/purple] (other than forcing the user to enter it twice).

[blue]Your thoughts?[/blue]

Calvin.gif
See Ya! . . . . . .
 
Ace
The fear is kind of a combination of both. The problem is the number that I refer to is the Employee ID number, but some of the entries will have them and some are in the process of being hired and won't, and a few will be subcontractors who need to be in the system but do not fit into our employee ID number.

I'm not as concerned with duplicate entries as I am with wrong entries, and that is why I'm trying to impliment the double entry (at my supervisors orders). Its really a fear that an ID like 123456789 would be entered 123446789. The data entry has never been really centralized, nor effectively QC'd. It will be more centralized due to the database but the QCing is really only going to be what I can put into the database to prevent errors (which causes me much consernation in other areas).
 
Eupher

I'm doing something wrong trying to adjust the code to what you are suggesting.

[purple]
Private Sub EmpID#_BeforeUpdate(Cancel As Integer)

If Me![EmpID# Double Entry] <> Me![EmpID#] Then
MsgBox "EmpID# numbers do not match please re-enter"
Me![EmpID# Double Entry].Undo
End If

End Sub
[/purple]

It will give the error message, but it updates the field in the table. I tried changing the last part the [purple]
Me![EmpID# Double Entry].Undo[purple] to [green]Me![EmpID#].Undo[/green] thinking I had screwed up, but that didn't do anything either.

I guess the question is this... How do I design it so if the information in [EmpID# Double Entry] <> [EmpID#] then both fields are set back to blank and the person who should have been in [EmpID#] gets sent back to [EmpID# Double Entry] to re-enter the number?

(The sent back to the first field part isn't actually necesary, it would just be nice).

Thank you for your help!
 
Lunatic,

Sorry, my mistake. You need the "Cancel = True" line after all.

Ken S.
 
Lunatic,

This might actually be one of the times where you want to validate your data in the AfterUpdate event, because the possibility exists that it is the first ID entry that is wrong, not the 2nd. So if the validation fails, you probably do indeed want to clear the 2nd ID field and set focus to the 1st ID field. And the BeforeUpdate event makes that problematic. Try this in the 2nd field's AfterUpdate event:
Code:
If Me![EmpID# Double Entry] <> Me![EmpID#] Then
    MsgBox "EmpID# numbers do not match please re-enter"
    Me![EmpID# Double Entry]= Null
    Me![EmpID#].SetFocus
End If
HTH,

Ken S.
 
Eupher
THANK YOU! That worked. I ran into some problems because I had hidden [EmpID# Double Entry] until the LostFocus event was run, which caused a circular problem (can't .SetFocus because its hidden until the current focus is lost).

To make it nice and clean for anyone in the future, here is all the code (and it seems to work):
Code:
Private Sub EmpID#_AfterUpdate()
  
   If Me![EmpID# Double Entry] <> Me![EmpID#] Then
      MsgBox "EmpID# numbers do not match please re-enter"
      Me![EmpID#] = Null
      Me![EmpID# Double Entry] = Null
      Me![EmpID# Double Entry].Visible = True
      Me![EmpID# Double Entry].SetFocus
      Cancel = True
   End If

End Sub

Private Sub EmpID#_GotFocus()
 
    Forms![FingerPrint].[EmpID# Double Entry].Visible = False
   
End Sub

Everyone thanks again for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top