A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Unique entry



 
 
Thread Tools Display Modes
  #21  
Old October 28th, 2005, 12:09 AM
Chris
external usenet poster
 
Posts: n/a
Default Unique entry

I pasted this:

Private Sub Symbol_ID_BeforeUpdate(Cancel As Integer)
If DCount("*", "Borrowing", _
"[Symbol ID]='" & Nz(Me![Symbol ID].Value, "") & "'") 0 Then
MsgBox "The value already exists!"
Cancel = True
End If
End Sub


Got this message:

---------------------------
Microsoft Office Access
---------------------------
The value already exists!
---------------------------
OK
---------------------------

And have to close out saying "Microsoft access may have encountered an
error while trying to save a record. If you close this object now the
changes you made will be lost. So you want to close the database
object anyways?"

Chris

  #22  
Old October 28th, 2005, 12:28 AM
Ken Snell [MVP]
external usenet poster
 
Posts: n/a
Default Unique entry

Sounds like you're trying to close the form after you enter a value but
before you moved the focus from the control. Your very early post said you
were tabbing from the control. Are you closing the form using the "red X"
instead of tabbing from the control?

It will be helpful if you describe the sequence of things that you want to
do on this form.

--

Ken Snell
MS ACCESS MVP

"Chris" wrote in message
oups.com...
I pasted this:

Private Sub Symbol_ID_BeforeUpdate(Cancel As Integer)
If DCount("*", "Borrowing", _
"[Symbol ID]='" & Nz(Me![Symbol ID].Value, "") & "'") 0 Then
MsgBox "The value already exists!"
Cancel = True
End If
End Sub


Got this message:

---------------------------
Microsoft Office Access
---------------------------
The value already exists!
---------------------------
OK
---------------------------

And have to close out saying "Microsoft access may have encountered an
error while trying to save a record. If you close this object now the
changes you made will be lost. So you want to close the database
object anyways?"

Chris



  #23  
Old October 28th, 2005, 01:22 AM
Chris
external usenet poster
 
Posts: n/a
Default Unique entry

If my last symbol keyed is a good one it all works fine, but if the
last symbol I key is a duplicate I am stuck!

I key the symbol - hit tab & get this message:

---------------------------
Microsoft Office Access
---------------------------
The value already exists!
---------------------------
OK
---------------------------

I hit ok. The symbol I typed is still there. I delete it and then
close out because I am done. It is my last entry & it does not want me
to exit because it knows I started a new record & did not complete it.

Chris

  #24  
Old October 28th, 2005, 01:57 AM
Chris
external usenet poster
 
Posts: n/a
Default Unique entry

See above first.

Possibly this is just the way I will have to exit - & live with it -
since it knows this is now an uncompleted form?

Chris

  #25  
Old October 28th, 2005, 02:54 AM
Ken Snell [MVP]
external usenet poster
 
Posts: n/a
Default Unique entry

OK - let's add one step to your code -- the Undo method for the bound
control:.

Private Sub Symbol_ID_BeforeUpdate(Cancel As Integer)
If DCount("*", "Borrowing", _
"[Symbol ID]='" & Nz(Me![Symbol ID].Value, "") & "'") 0 Then
MsgBox "The value already exists!"
Cancel = True
Me![Symbol ID].Undo
End If
End Sub

That will eliminate the problem of you having to delete the entry that you'd
made.

Now, if you want to cancel the entry of the new record entirely, then we can
add one more step to undo the entire new record:

Private Sub Symbol_ID_BeforeUpdate(Cancel As Integer)
If DCount("*", "Borrowing", _
"[Symbol ID]='" & Nz(Me![Symbol ID].Value, "") & "'") 0 Then
MsgBox "The value already exists!"
Cancel = True
Me![Symbol ID].Undo
Me.Undo
End If
End Sub

--

Ken Snell
MS ACCESS MVP

"Chris" wrote in message
oups.com...
If my last symbol keyed is a good one it all works fine, but if the
last symbol I key is a duplicate I am stuck!

I key the symbol - hit tab & get this message:

---------------------------
Microsoft Office Access
---------------------------
The value already exists!
---------------------------
OK
---------------------------

I hit ok. The symbol I typed is still there. I delete it and then
close out because I am done. It is my last entry & it does not want me
to exit because it knows I started a new record & did not complete it.

Chris



  #26  
Old October 28th, 2005, 03:11 AM
Chris
external usenet poster
 
Posts: n/a
Default Unique entry

You are an absolute genius!!! It worked and did exactly what I need it
to!! Thank you so much for your help!

Chris Agostino

  #27  
Old October 28th, 2005, 03:46 AM
Ken Snell [MVP]
external usenet poster
 
Posts: n/a
Default Unique entry

You're welcome... glad it worked ok.

--

Ken Snell
MS ACCESS MVP

"Chris" wrote in message
oups.com...
You are an absolute genius!!! It worked and did exactly what I need it
to!! Thank you so much for your help!

Chris Agostino



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Memo Field Sam General Discussion 12 November 10th, 2005 09:16 PM
How do I make a unique entry Lynn Bales New Users 9 August 15th, 2005 10:55 PM
How do I create a table of unique records from two or more tables Rubble Running & Setting Up Queries 5 June 23rd, 2005 12:05 PM
Query on unique Steven Running & Setting Up Queries 3 February 5th, 2005 12:24 AM
decipher log of scanpst.exe km General Discussion 0 July 18th, 2004 09:00 AM


All times are GMT +1. The time now is 07:06 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.