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  

duplicate number with messagebox & textbox



 
 
Thread Tools Display Modes
  #1  
Old December 4th, 2006, 02:21 PM posted to microsoft.public.access.forms
syedalna via AccessMonster.com
external usenet poster
 
Posts: 9
Default duplicate number with messagebox & textbox

i have a subform, textbox1 is number format and textbox2 is text format..and
both are not a primarykey. subform data is from query (though this will help).


is there away to avoid duplication number in textbox1. when there is a
duplication, it show message box with the detail of textbox2.

Your help is greatly appreciated to solve this matter.


Thank you in advane

--
Message posted via http://www.accessmonster.com

  #2  
Old December 4th, 2006, 03:25 PM posted to microsoft.public.access.forms
Sean
external usenet poster
 
Posts: 13
Default duplicate number with messagebox & textbox


"syedalna via AccessMonster.com" u29806@uwe wrote in message
news:6a42151b00d85@uwe...
i have a subform, textbox1 is number format and textbox2 is text
format..and
both are not a primarykey. subform data is from query (though this will
help).


is there away to avoid duplication number in textbox1. when there is a
duplication, it show message box with the detail of textbox2.

Your help is greatly appreciated to solve this matter.


Thank you in advane

--
Message posted via http://www.accessmonster.com



Add an event to the 'on lost focus' of both boxes...

if (cstr(textbox1)) = textbox2) then
msgbox "They're the same!"
end if

Should do the trick, or at least get you in the right direction.

Sean



  #3  
Old December 4th, 2006, 03:29 PM posted to microsoft.public.access.forms
Al Campagna
external usenet poster
 
Posts: 421
Default duplicate number with messagebox & textbox

syedalna ,
Use the BeforeUpdate event of TextBox1 to do a Dlookup against all the other
TextBox1 values in your table.
If so... set Cancel = True.
If not...continue normally

Not sure I understand the MsgBox you want to display on dupes... but...

Dim Prompt as String
Dim Title as String
Prompt = Me.TextBox2
Title = "Duplicate Value"
MsgBox Prompt, vbOKOnly, Title

--
hth
Al Campagna
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions


"syedalna via AccessMonster.com" u29806@uwe wrote in message news:6a42151b00d85@uwe...
i have a subform, textbox1 is number format and textbox2 is text format..and
both are not a primarykey. subform data is from query (though this will help).


is there away to avoid duplication number in textbox1. when there is a
duplication, it show message box with the detail of textbox2.

Your help is greatly appreciated to solve this matter.


Thank you in advane

--
Message posted via http://www.accessmonster.com



  #4  
Old December 5th, 2006, 02:10 AM posted to microsoft.public.access.forms
syedalna via AccessMonster.com
external usenet poster
 
Posts: 9
Default duplicate number with messagebox & textbox

Al Campagna,

Your code is what i'm looking for.

It did identified the duplication & show the message box of the textbox2...
and ADD the record to the table.. I need to have a "Yes" & "No" on the
message box..where
if "Yes" = it will add the record that enter
if "No"= it will Not add the record and the form will return to it natural
state of Add New Data Entry (Add New Record).


Could you show me the code. I do appreciate it very much.

Thanks for your code

Al Campagna wrote:
syedalna ,
Use the BeforeUpdate event of TextBox1 to do a Dlookup against all the other
TextBox1 values in your table.
If so... set Cancel = True.
If not...continue normally

Not sure I understand the MsgBox you want to display on dupes... but...

Dim Prompt as String
Dim Title as String
Prompt = Me.TextBox2
Title = "Duplicate Value"
MsgBox Prompt, vbOKOnly, Title

i have a subform, textbox1 is number format and textbox2 is text format..and
both are not a primarykey. subform data is from query (though this will help).

[quoted text clipped - 5 lines]

Thank you in advane


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200612/1

  #5  
Old December 5th, 2006, 04:42 AM posted to microsoft.public.access.forms
Al Campagna
external usenet poster
 
Posts: 421
Default duplicate number with messagebox & textbox

syedalna,
Set up the MsgBox This way...

Dim Prompt as String, Title as String, Response as Integer
Prompt = "Duplicate " & Me.TextBox2 & vbCrLf & " Do you want to add it?"
Title = "Duplicate Value"
Response = MsgBox (Prompt, vbYesNo, Title)
If Response = vbYes Then
'code to add the record
Else
'code to not add the record
End If

--
hth
Al Campagna
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions



"syedalna via AccessMonster.com" u29806@uwe wrote in message news:6a484619c9535@uwe...
Al Campagna,

Your code is what i'm looking for.

It did identified the duplication & show the message box of the textbox2...
and ADD the record to the table.. I need to have a "Yes" & "No" on the
message box..where
if "Yes" = it will add the record that enter
if "No"= it will Not add the record and the form will return to it natural
state of Add New Data Entry (Add New Record).


Could you show me the code. I do appreciate it very much.

Thanks for your code

Al Campagna wrote:
syedalna ,
Use the BeforeUpdate event of TextBox1 to do a Dlookup against all the other
TextBox1 values in your table.
If so... set Cancel = True.
If not...continue normally

Not sure I understand the MsgBox you want to display on dupes... but...

Dim Prompt as String
Dim Title as String
Prompt = Me.TextBox2
Title = "Duplicate Value"
MsgBox Prompt, vbOKOnly, Title

i have a subform, textbox1 is number format and textbox2 is text format..and
both are not a primarykey. subform data is from query (though this will help).

[quoted text clipped - 5 lines]

Thank you in advane


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200612/1



  #6  
Old December 9th, 2006, 08:44 AM posted to microsoft.public.access.forms
syedalna via AccessMonster.com
external usenet poster
 
Posts: 9
Default duplicate number with messagebox & textbox

al campagna,
This code prompt me (Yes/ No) even if the data has NO DUPLICATES..

how could i do it, like this:-

if data duplicates= it will Not add the record and the form will return to it
natural state, add new record
if date has NO DUPLICATES= it will add data automatically, withour promp me
any thing ( like noting happen)

your suggestion is much appciated


syedalna wrote:
Al Campagna,

Your code is what i'm looking for.

It did identified the duplication & show the message box of the textbox2...
and ADD the record to the table.. I need to have a "Yes" & "No" on the
message box..where
if "Yes" = it will add the record that enter
if "No"= it will Not add the record and the form will return to it natural
state of Add New Data Entry (Add New Record).

Could you show me the code. I do appreciate it very much.

Thanks for your code

syedalna ,
Use the BeforeUpdate event of TextBox1 to do a Dlookup against all the other

[quoted text clipped - 15 lines]

Thank you in advane


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200612/1

  #7  
Old December 13th, 2006, 03:15 PM posted to microsoft.public.access.forms
Al Campagna
external usenet poster
 
Posts: 421
Default duplicate number with messagebox & textbox

syedalna,
I've been on vacation for a week, so sorry for the dealy in responding.
I thought you just needed the message box part....
All you would need to do is a Dlookup just before the MsgBox to determine if a
duplicate exits, then the Yes/No to add or not.

Dim Prompt as String, Title as String, Response as Integer
Refresh
If IsNull ("[YourFieldName]", "yourTable", "YourField = " & Textbox1) Then
Prompt = "Duplicate " & Me.TextBox2 & vbCrLf & " Do you want to add it?"
Title = "Duplicate Value"
Response = MsgBox (Prompt, vbYesNo, Title)
If Response = vbYes Then
'code to add the record
Else
'code to not add the record
End If
Else
Exit Sub
End Sub

I banged this out, so please check for any typos.

--
hth
Al Campagna
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions


"syedalna via AccessMonster.com" u29806@uwe wrote in message news:6a7e02010a14f@uwe...
al campagna,
This code prompt me (Yes/ No) even if the data has NO DUPLICATES..

how could i do it, like this:-

if data duplicates= it will Not add the record and the form will return to it
natural state, add new record
if date has NO DUPLICATES= it will add data automatically, withour promp me
any thing ( like noting happen)

your suggestion is much appciated


syedalna wrote:
Al Campagna,

Your code is what i'm looking for.

It did identified the duplication & show the message box of the textbox2...
and ADD the record to the table.. I need to have a "Yes" & "No" on the
message box..where
if "Yes" = it will add the record that enter
if "No"= it will Not add the record and the form will return to it natural
state of Add New Data Entry (Add New Record).

Could you show me the code. I do appreciate it very much.

Thanks for your code

syedalna ,
Use the BeforeUpdate event of TextBox1 to do a Dlookup against all the other

[quoted text clipped - 15 lines]

Thank you in advane


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200612/1



 




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


All times are GMT +1. The time now is 11:07 AM.


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