Custom Duplicate warning

S

sashabaz

Hi all,

I am trying to create my own duplicate warning message. I have a query
running that counts the number of duplicates. This is connected to a form
(frmDuplicates). I want this form to appear ONLY if the duplicates field
([DupeCount]) in frmDuplicates is greater then 1.

I.E. User opens frmProject. frmDuplicates opens only if duplicates in form
(frmDuplicates) is greater than 0.

At the moment, I have the OnLoad Macro for frmProject set as - Requery and
OpenForm frmDuplicates (Where condition
=[Forms]![frmDuplicates]![DupeCount]>0). I think this isnt working because
it is asking for a value from the frmDuplicates before it is open, but im not
sure....

Hope someone can help me....
Thanks...
Sashabaz.
 
M

Mark A. Sam

I'm don't use Macros and don't want to figure them out, so I am going to
give you a VBA procedure to accomplish what you need done. You won't be
doing this from frmProject.

Open frmDuplicates in design view. Click on the On Open property in the
Forms' property sheet. A little button with three dots will appear on the
right. Click it and the code editor will appear. Copy and paste this code
between the lines which read Private... and End Sub:

If [Amount] > 1 Then
Cancel = True
End If

so when you have done that, it will look like this:

Private Sub Form_Open(Cancel As Integer)
If [DupeCount] > 1 Then
Cancel = True
End If
End Sub

Click the File menu option and close the Code window.

The method, Cancel = True will prevent the form from opening.

Save and close frmDuplicates and open frmProject. If you have described
the situation correctly this will work. If you have a problem, post back.

God Bless,

Mark A. Sam
 
S

sashabaz

Hi Mark..

I tried the code you said, but it doesnt seem to effect anything. At the
moment it just delays the initial showing of the duplicate warning until the
user changes their choice of project. This may be because I have a choice
option on frmProject. the user selects a project from a combo box on
frmProject which is then called by frmduplicates before the number of
duplicates for that project is counted (i.e. combo box is changed, frmProject
refreshes to show new project, frmDuplicates is called to show duplicates for
that project). I didnt make this clear in the last mail.

hope that clears up why its not working.....

thanks for the help...

Mark A. Sam said:
I'm don't use Macros and don't want to figure them out, so I am going to
give you a VBA procedure to accomplish what you need done. You won't be
doing this from frmProject.

Open frmDuplicates in design view. Click on the On Open property in the
Forms' property sheet. A little button with three dots will appear on the
right. Click it and the code editor will appear. Copy and paste this code
between the lines which read Private... and End Sub:

If [Amount] > 1 Then
Cancel = True
End If

so when you have done that, it will look like this:

Private Sub Form_Open(Cancel As Integer)
If [DupeCount] > 1 Then
Cancel = True
End If
End Sub

Click the File menu option and close the Code window.

The method, Cancel = True will prevent the form from opening.

Save and close frmDuplicates and open frmProject. If you have described
the situation correctly this will work. If you have a problem, post back.

God Bless,

Mark A. Sam

sashabaz said:
Hi all,

I am trying to create my own duplicate warning message. I have a query
running that counts the number of duplicates. This is connected to a form
(frmDuplicates). I want this form to appear ONLY if the duplicates field
([DupeCount]) in frmDuplicates is greater then 1.

I.E. User opens frmProject. frmDuplicates opens only if duplicates in
form
(frmDuplicates) is greater than 0.

At the moment, I have the OnLoad Macro for frmProject set as - Requery and
OpenForm frmDuplicates (Where condition
=[Forms]![frmDuplicates]![DupeCount]>0). I think this isnt working
because
it is asking for a value from the frmDuplicates before it is open, but im
not
sure....

Hope someone can help me....
Thanks...
Sashabaz.
 
M

Mark A. Sam

Posting this was an error:

If [Amount] > 1 Then
Cancel = True
End If

I did that on one of my DB's to test the code. It is this code that you
should have entered:
If [DupeCount] > 1 Then
Cancel = True
End If

If you posted the first procedure, use the second and let me know.

sashabaz said:
Hi Mark..

I tried the code you said, but it doesnt seem to effect anything. At the
moment it just delays the initial showing of the duplicate warning until
the
user changes their choice of project. This may be because I have a choice
option on frmProject. the user selects a project from a combo box on
frmProject which is then called by frmduplicates before the number of
duplicates for that project is counted (i.e. combo box is changed,
frmProject
refreshes to show new project, frmDuplicates is called to show duplicates
for
that project). I didnt make this clear in the last mail.

hope that clears up why its not working.....

thanks for the help...

Mark A. Sam said:
I'm don't use Macros and don't want to figure them out, so I am going to
give you a VBA procedure to accomplish what you need done. You won't be
doing this from frmProject.

Open frmDuplicates in design view. Click on the On Open property in the
Forms' property sheet. A little button with three dots will appear on
the
right. Click it and the code editor will appear. Copy and paste this
code
between the lines which read Private... and End Sub:

If [Amount] > 1 Then
Cancel = True
End If

so when you have done that, it will look like this:

Private Sub Form_Open(Cancel As Integer)
If [DupeCount] > 1 Then
Cancel = True
End If
End Sub

Click the File menu option and close the Code window.

The method, Cancel = True will prevent the form from opening.

Save and close frmDuplicates and open frmProject. If you have described
the situation correctly this will work. If you have a problem, post
back.

God Bless,

Mark A. Sam

sashabaz said:
Hi all,

I am trying to create my own duplicate warning message. I have a query
running that counts the number of duplicates. This is connected to a
form
(frmDuplicates). I want this form to appear ONLY if the duplicates
field
([DupeCount]) in frmDuplicates is greater then 1.

I.E. User opens frmProject. frmDuplicates opens only if duplicates in
form
(frmDuplicates) is greater than 0.

At the moment, I have the OnLoad Macro for frmProject set as - Requery
and
OpenForm frmDuplicates (Where condition
=[Forms]![frmDuplicates]![DupeCount]>0). I think this isnt working
because
it is asking for a value from the frmDuplicates before it is open, but
im
not
sure....

Hope someone can help me....
Thanks...
Sashabaz.
 
S

sashabaz

I already tried the [DupeCount] code... Thought the [Amount] was the
incorrect field....

Mark A. Sam said:
Posting this was an error:

If [Amount] > 1 Then
Cancel = True
End If

I did that on one of my DB's to test the code. It is this code that you
should have entered:
If [DupeCount] > 1 Then
Cancel = True
End If

If you posted the first procedure, use the second and let me know.

sashabaz said:
Hi Mark..

I tried the code you said, but it doesnt seem to effect anything. At the
moment it just delays the initial showing of the duplicate warning until
the
user changes their choice of project. This may be because I have a choice
option on frmProject. the user selects a project from a combo box on
frmProject which is then called by frmduplicates before the number of
duplicates for that project is counted (i.e. combo box is changed,
frmProject
refreshes to show new project, frmDuplicates is called to show duplicates
for
that project). I didnt make this clear in the last mail.

hope that clears up why its not working.....

thanks for the help...

Mark A. Sam said:
I'm don't use Macros and don't want to figure them out, so I am going to
give you a VBA procedure to accomplish what you need done. You won't be
doing this from frmProject.

Open frmDuplicates in design view. Click on the On Open property in the
Forms' property sheet. A little button with three dots will appear on
the
right. Click it and the code editor will appear. Copy and paste this
code
between the lines which read Private... and End Sub:

If [Amount] > 1 Then
Cancel = True
End If

so when you have done that, it will look like this:

Private Sub Form_Open(Cancel As Integer)
If [DupeCount] > 1 Then
Cancel = True
End If
End Sub

Click the File menu option and close the Code window.

The method, Cancel = True will prevent the form from opening.

Save and close frmDuplicates and open frmProject. If you have described
the situation correctly this will work. If you have a problem, post
back.

God Bless,

Mark A. Sam

Hi all,

I am trying to create my own duplicate warning message. I have a query
running that counts the number of duplicates. This is connected to a
form
(frmDuplicates). I want this form to appear ONLY if the duplicates
field
([DupeCount]) in frmDuplicates is greater then 1.

I.E. User opens frmProject. frmDuplicates opens only if duplicates in
form
(frmDuplicates) is greater than 0.

At the moment, I have the OnLoad Macro for frmProject set as - Requery
and
OpenForm frmDuplicates (Where condition
=[Forms]![frmDuplicates]![DupeCount]>0). I think this isnt working
because
it is asking for a value from the frmDuplicates before it is open, but
im
not
sure....

Hope someone can help me....
Thanks...
Sashabaz.
 
M

Mark A. Sam

I apologize. I am thinking backwards. Try this:

If [DupeCount] <1 Then
Cancel = True
End If

You want the form to open if there are dups, when [DupeCount] = 1 or
greater. When it is <1 then the form doesn't need to open.

If this doesn't work, then it is a problem with [DupeCount]. The query
which feeds it should only result in one record if opened. If there are
multiple records, then you need to rethink this.




sashabaz said:
I already tried the [DupeCount] code... Thought the [Amount] was the
incorrect field....

Mark A. Sam said:
Posting this was an error:

If [Amount] > 1 Then
Cancel = True
End If

I did that on one of my DB's to test the code. It is this code that you
should have entered:
If [DupeCount] > 1 Then
Cancel = True
End If

If you posted the first procedure, use the second and let me know.

sashabaz said:
Hi Mark..

I tried the code you said, but it doesnt seem to effect anything. At
the
moment it just delays the initial showing of the duplicate warning
until
the
user changes their choice of project. This may be because I have a
choice
option on frmProject. the user selects a project from a combo box on
frmProject which is then called by frmduplicates before the number of
duplicates for that project is counted (i.e. combo box is changed,
frmProject
refreshes to show new project, frmDuplicates is called to show
duplicates
for
that project). I didnt make this clear in the last mail.

hope that clears up why its not working.....

thanks for the help...

:

I'm don't use Macros and don't want to figure them out, so I am going
to
give you a VBA procedure to accomplish what you need done. You won't
be
doing this from frmProject.

Open frmDuplicates in design view. Click on the On Open property in
the
Forms' property sheet. A little button with three dots will appear on
the
right. Click it and the code editor will appear. Copy and paste this
code
between the lines which read Private... and End Sub:

If [Amount] > 1 Then
Cancel = True
End If

so when you have done that, it will look like this:

Private Sub Form_Open(Cancel As Integer)
If [DupeCount] > 1 Then
Cancel = True
End If
End Sub

Click the File menu option and close the Code window.

The method, Cancel = True will prevent the form from opening.

Save and close frmDuplicates and open frmProject. If you have
described
the situation correctly this will work. If you have a problem, post
back.

God Bless,

Mark A. Sam

Hi all,

I am trying to create my own duplicate warning message. I have a
query
running that counts the number of duplicates. This is connected to
a
form
(frmDuplicates). I want this form to appear ONLY if the duplicates
field
([DupeCount]) in frmDuplicates is greater then 1.

I.E. User opens frmProject. frmDuplicates opens only if duplicates
in
form
(frmDuplicates) is greater than 0.

At the moment, I have the OnLoad Macro for frmProject set as -
Requery
and
OpenForm frmDuplicates (Where condition
=[Forms]![frmDuplicates]![DupeCount]>0). I think this isnt working
because
it is asking for a value from the frmDuplicates before it is open,
but
im
not
sure....

Hope someone can help me....
Thanks...
Sashabaz.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top