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
|
|||
|
|||
Check for duplicate with multiple criteria
My table contains a field labled "Case Number" and another field labled "Date
Completed". I have created an input form and included code to check for duplicate case numbers. A msgbox appears with a warning. I would like the code to check for a duplicate case number and then check the "Date Completed" field to see if it is blank. If it is blank I would like the existing record to open. If the date completed field is not blank I would like to continue entering data in the form to create a new record. The code I am currently using is: Private Sub Case_Number_BeforeUpdate(Cancel As Integer) If DCount("*", "Copy of DIV 3 ICT Database", "[Case Number] = '" & Me![Case Number] & "'") 0 Then MsgBox "This item already exists in the table." Cancel = True Me.Undo End If End Sub How can I incorporate the changes? Any help is greatly appreciated. |
#2
|
|||
|
|||
Check for duplicate with multiple criteria
On Sat, 22 May 2010 18:23:01 -0700, mbparks
wrote: I'm not sure I follow you. You write: "If it is blank I would like the existing record to open". Open how? Do you mean "open another form with the correct casenumber preselected", or do you mean "in the current form, move to the record with the correct casenumber"? Or? It is nearly impossible and not recommended to use ONE control both for lookups as for data-entry. -Tom. Microsoft Access MVP My table contains a field labled "Case Number" and another field labled "Date Completed". I have created an input form and included code to check for duplicate case numbers. A msgbox appears with a warning. I would like the code to check for a duplicate case number and then check the "Date Completed" field to see if it is blank. If it is blank I would like the existing record to open. If the date completed field is not blank I would like to continue entering data in the form to create a new record. The code I am currently using is: Private Sub Case_Number_BeforeUpdate(Cancel As Integer) If DCount("*", "Copy of DIV 3 ICT Database", "[Case Number] = '" & Me![Case Number] & "'") 0 Then MsgBox "This item already exists in the table." Cancel = True Me.Undo End If End Sub How can I incorporate the changes? Any help is greatly appreciated. |
#3
|
|||
|
|||
Check for duplicate with multiple criteria
In the current form, move the the record with the correct case number.
"Tom van Stiphout" wrote: On Sat, 22 May 2010 18:23:01 -0700, mbparks wrote: I'm not sure I follow you. You write: "If it is blank I would like the existing record to open". Open how? Do you mean "open another form with the correct casenumber preselected", or do you mean "in the current form, move to the record with the correct casenumber"? Or? It is nearly impossible and not recommended to use ONE control both for lookups as for data-entry. -Tom. Microsoft Access MVP My table contains a field labled "Case Number" and another field labled "Date Completed". I have created an input form and included code to check for duplicate case numbers. A msgbox appears with a warning. I would like the code to check for a duplicate case number and then check the "Date Completed" field to see if it is blank. If it is blank I would like the existing record to open. If the date completed field is not blank I would like to continue entering data in the form to create a new record. The code I am currently using is: Private Sub Case_Number_BeforeUpdate(Cancel As Integer) If DCount("*", "Copy of DIV 3 ICT Database", "[Case Number] = '" & Me![Case Number] & "'") 0 Then MsgBox "This item already exists in the table." Cancel = True Me.Undo End If End Sub How can I incorporate the changes? Any help is greatly appreciated. . |
#4
|
|||
|
|||
Check for duplicate with multiple criteria
On Sat, 22 May 2010 22:32:01 -0700, mbparks
wrote: I'm assuming you meant "move to the record with the correct casenumber". This is accomplished with the bookmark technique: with me.recordsetclone .findfirst "[case number]=" & me.myCasenumberControlName if not .nomatch then me.bookmark = .bookmark end if end with -Tom. Microsoft Access MVP In the current form, move the the record with the correct case number. "Tom van Stiphout" wrote: On Sat, 22 May 2010 18:23:01 -0700, mbparks wrote: I'm not sure I follow you. You write: "If it is blank I would like the existing record to open". Open how? Do you mean "open another form with the correct casenumber preselected", or do you mean "in the current form, move to the record with the correct casenumber"? Or? It is nearly impossible and not recommended to use ONE control both for lookups as for data-entry. -Tom. Microsoft Access MVP My table contains a field labled "Case Number" and another field labled "Date Completed". I have created an input form and included code to check for duplicate case numbers. A msgbox appears with a warning. I would like the code to check for a duplicate case number and then check the "Date Completed" field to see if it is blank. If it is blank I would like the existing record to open. If the date completed field is not blank I would like to continue entering data in the form to create a new record. The code I am currently using is: Private Sub Case_Number_BeforeUpdate(Cancel As Integer) If DCount("*", "Copy of DIV 3 ICT Database", "[Case Number] = '" & Me![Case Number] & "'") 0 Then MsgBox "This item already exists in the table." Cancel = True Me.Undo End If End Sub How can I incorporate the changes? Any help is greatly appreciated. . |
#5
|
|||
|
|||
Check for duplicate with multiple criteria
Hi Tom,
I'm still having trouble with this. In your reply you have " & me.myCasenumberControlName". My control is a text box called Case Number. I've entered it as "myCaseNumber" and "my [Case Number]. Neither are working. Please help. "Tom van Stiphout" wrote: On Sat, 22 May 2010 22:32:01 -0700, mbparks wrote: I'm assuming you meant "move to the record with the correct casenumber". This is accomplished with the bookmark technique: with me.recordsetclone .findfirst "[case number]=" & me.myCasenumberControlName if not .nomatch then me.bookmark = .bookmark end if end with -Tom. Microsoft Access MVP In the current form, move the the record with the correct case number. "Tom van Stiphout" wrote: On Sat, 22 May 2010 18:23:01 -0700, mbparks wrote: I'm not sure I follow you. You write: "If it is blank I would like the existing record to open". Open how? Do you mean "open another form with the correct casenumber preselected", or do you mean "in the current form, move to the record with the correct casenumber"? Or? It is nearly impossible and not recommended to use ONE control both for lookups as for data-entry. -Tom. Microsoft Access MVP My table contains a field labled "Case Number" and another field labled "Date Completed". I have created an input form and included code to check for duplicate case numbers. A msgbox appears with a warning. I would like the code to check for a duplicate case number and then check the "Date Completed" field to see if it is blank. If it is blank I would like the existing record to open. If the date completed field is not blank I would like to continue entering data in the form to create a new record. The code I am currently using is: Private Sub Case_Number_BeforeUpdate(Cancel As Integer) If DCount("*", "Copy of DIV 3 ICT Database", "[Case Number] = '" & Me![Case Number] & "'") 0 Then MsgBox "This item already exists in the table." Cancel = True Me.Undo End If End Sub How can I incorporate the changes? Any help is greatly appreciated. . . |
Thread Tools | |
Display Modes | |
|
|