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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|