If statement

D

deb

In my form...
This is associated with the button that calls the getfilename sub.

The below code is suppose to check 3 fields to see if it is a duplicate
record. If it is a duplicate then bring up the msgbox to click OK to go back
to the record and make changes or Cancel to delete the record. If the record
is not a duplicate then it should move on to the getfilename.

The first If statement works great but when combined with the msgbox stmt,
it thinks all records are duplicates.

If DCount("*", "tSchedImages", "[ProjID] = " & Me![ProjID]) > 0 And
DCount("*", "tSchedImages", "[Page] = " & Me![Page]) And DCount("*",
"tSchedImages", "[ReportDtID] = " & Me![ReportDtID]) <> 1 Then
blnOK = Confirm("This schedule is a duplicate. Click 'Ok' to change input,
or 'Cancel' to delete record.")
Cancel = True

If Not blnOK Then
'set all required fields so record can be deleted.
Me![Photo] = "none"
Me![ReportDtID] = 1
Me![Page] = 999999999
Me.Undo
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
End If
Else
'Use the Office File Open dialog to get a file name to use
' as a picture.
getFileName

End If


Please help!!
 
D

Douglas J. Steele

You're not comparing DCount("*", "tSchedImages", "[Page] = " & Me![Page])
to anything. That means that as long as it's non-zero, it's going to be
treated as True. Is that what you want?
 
D

deb

I thought that it was comparing the 3 fields in the table to the field in the
form. It seems to work ok if it doe not have the other...

blnOK = Confirm("This schedule is a duplicate. Click 'Ok' to change input,
or 'Cancel' to delete record.")
Cancel = True

If Not blnOK Then
'set all required fields so record can be deleted.
Me![Photo] = "none"
Me![ReportDtID] = 1
Me![Page] = 999999999
Me.Undo
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
End If

--
deb


Douglas J. Steele said:
You're not comparing DCount("*", "tSchedImages", "[Page] = " & Me![Page])
to anything. That means that as long as it's non-zero, it's going to be
treated as True. Is that what you want?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


deb said:
In my form...
This is associated with the button that calls the getfilename sub.

The below code is suppose to check 3 fields to see if it is a duplicate
record. If it is a duplicate then bring up the msgbox to click OK to go
back
to the record and make changes or Cancel to delete the record. If the
record
is not a duplicate then it should move on to the getfilename.

The first If statement works great but when combined with the msgbox stmt,
it thinks all records are duplicates.

If DCount("*", "tSchedImages", "[ProjID] = " & Me![ProjID]) > 0 And
DCount("*", "tSchedImages", "[Page] = " & Me![Page]) And DCount("*",
"tSchedImages", "[ReportDtID] = " & Me![ReportDtID]) <> 1 Then
blnOK = Confirm("This schedule is a duplicate. Click 'Ok' to change input,
or 'Cancel' to delete record.")
Cancel = True

If Not blnOK Then
'set all required fields so record can be deleted.
Me![Photo] = "none"
Me![ReportDtID] = 1
Me![Page] = 999999999
Me.Undo
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
End If
Else
'Use the Office File Open dialog to get a file name to use
' as a picture.
getFileName

End If


Please help!!
 
D

deb

I am open to other suggestions...

I am trying to verivy if the record that I am inputting is not a duplicate.
I want to make this verification when a button is clicked to open a "find
file" feature.

I have the table set with the correct keys and it will verify when exiting
the form but I need it to verify earlier so the user does not have to complet
the whole form before they realize it is a duplicate.

Thanks in advance
--
deb


Douglas J. Steele said:
You're not comparing DCount("*", "tSchedImages", "[Page] = " & Me![Page])
to anything. That means that as long as it's non-zero, it's going to be
treated as True. Is that what you want?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


deb said:
In my form...
This is associated with the button that calls the getfilename sub.

The below code is suppose to check 3 fields to see if it is a duplicate
record. If it is a duplicate then bring up the msgbox to click OK to go
back
to the record and make changes or Cancel to delete the record. If the
record
is not a duplicate then it should move on to the getfilename.

The first If statement works great but when combined with the msgbox stmt,
it thinks all records are duplicates.

If DCount("*", "tSchedImages", "[ProjID] = " & Me![ProjID]) > 0 And
DCount("*", "tSchedImages", "[Page] = " & Me![Page]) And DCount("*",
"tSchedImages", "[ReportDtID] = " & Me![ReportDtID]) <> 1 Then
blnOK = Confirm("This schedule is a duplicate. Click 'Ok' to change input,
or 'Cancel' to delete record.")
Cancel = True

If Not blnOK Then
'set all required fields so record can be deleted.
Me![Photo] = "none"
Me![ReportDtID] = 1
Me![Page] = 999999999
Me.Undo
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
End If
Else
'Use the Office File Open dialog to get a file name to use
' as a picture.
getFileName

End If


Please help!!
 
D

Douglas J. Steele

Assuming that a row is a duplicate if all 3 of ProjID, Page and ReportDtID
are the same, I'd think you want:

If DCount("*", "tSchedImages", "[ProjID] = " & _
Me![ProjID] & " And [Page] = " & Me![Page] & _
" And [ReportDtID] = " & Me![ReportDtID]) > 0 Then



--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


deb said:
I am open to other suggestions...

I am trying to verivy if the record that I am inputting is not a
duplicate.
I want to make this verification when a button is clicked to open a "find
file" feature.

I have the table set with the correct keys and it will verify when exiting
the form but I need it to verify earlier so the user does not have to
complet
the whole form before they realize it is a duplicate.

Thanks in advance
--
deb


Douglas J. Steele said:
You're not comparing DCount("*", "tSchedImages", "[Page] = " & Me![Page])
to anything. That means that as long as it's non-zero, it's going to be
treated as True. Is that what you want?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


deb said:
In my form...
This is associated with the button that calls the getfilename sub.

The below code is suppose to check 3 fields to see if it is a duplicate
record. If it is a duplicate then bring up the msgbox to click OK to go
back
to the record and make changes or Cancel to delete the record. If the
record
is not a duplicate then it should move on to the getfilename.

The first If statement works great but when combined with the msgbox
stmt,
it thinks all records are duplicates.

If DCount("*", "tSchedImages", "[ProjID] = " & Me![ProjID]) > 0 And
DCount("*", "tSchedImages", "[Page] = " & Me![Page]) And DCount("*",
"tSchedImages", "[ReportDtID] = " & Me![ReportDtID]) <> 1 Then
blnOK = Confirm("This schedule is a duplicate. Click 'Ok' to change
input,
or 'Cancel' to delete record.")
Cancel = True

If Not blnOK Then
'set all required fields so record can be deleted.
Me![Photo] = "none"
Me![ReportDtID] = 1
Me![Page] = 999999999
Me.Undo
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
End If
Else
'Use the Office File Open dialog to get a file name to use
' as a picture.
getFileName

End If


Please help!!
 
D

deb

Thank you for your help!!! This is making me crazy.
I am not having problems with the part of the code you have noted. It works
fine. I need help with the other portions of the code.

When I have the below code added it thinks every record is a duplicate. If
I take this out, it works fine. I think I have my ifs in the wrong place.

When I have a duplicate it promps and works to OK or delete
but
when the record is not a duplicate it still promps. When it is not a
duplicate how do I make it go directly to the getfilename and skpi the prompt?

blnOK = Confirm("This schedule is a duplicate. Click 'Ok' to change input,
or 'Cancel' to delete record.")
Cancel = True

If Not blnOK Then
'set all required fields so record can be deleted.
Me![Photo] = "none"
Me![ReportDtID] = 1
Me![Page] = 999999999
Me.Undo
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
End If

--
deb


Douglas J. Steele said:
Assuming that a row is a duplicate if all 3 of ProjID, Page and ReportDtID
are the same, I'd think you want:

If DCount("*", "tSchedImages", "[ProjID] = " & _
Me![ProjID] & " And [Page] = " & Me![Page] & _
" And [ReportDtID] = " & Me![ReportDtID]) > 0 Then



--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


deb said:
I am open to other suggestions...

I am trying to verivy if the record that I am inputting is not a
duplicate.
I want to make this verification when a button is clicked to open a "find
file" feature.

I have the table set with the correct keys and it will verify when exiting
the form but I need it to verify earlier so the user does not have to
complet
the whole form before they realize it is a duplicate.

Thanks in advance
--
deb


Douglas J. Steele said:
You're not comparing DCount("*", "tSchedImages", "[Page] = " & Me![Page])
to anything. That means that as long as it's non-zero, it's going to be
treated as True. Is that what you want?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


In my form...
This is associated with the button that calls the getfilename sub.

The below code is suppose to check 3 fields to see if it is a duplicate
record. If it is a duplicate then bring up the msgbox to click OK to go
back
to the record and make changes or Cancel to delete the record. If the
record
is not a duplicate then it should move on to the getfilename.

The first If statement works great but when combined with the msgbox
stmt,
it thinks all records are duplicates.

If DCount("*", "tSchedImages", "[ProjID] = " & Me![ProjID]) > 0 And
DCount("*", "tSchedImages", "[Page] = " & Me![Page]) And DCount("*",
"tSchedImages", "[ReportDtID] = " & Me![ReportDtID]) <> 1 Then
blnOK = Confirm("This schedule is a duplicate. Click 'Ok' to change
input,
or 'Cancel' to delete record.")
Cancel = True

If Not blnOK Then
'set all required fields so record can be deleted.
Me![Photo] = "none"
Me![ReportDtID] = 1
Me![Page] = 999999999
Me.Undo
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
End If
Else
'Use the Office File Open dialog to get a file name to use
' as a picture.
getFileName

End If


Please help!!
 
D

Douglas J. Steele

It strikes me that you are having problems with the DCount code if the
"duplicate" prompt always appears, since that's what the code's supposed to
control!

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


deb said:
Thank you for your help!!! This is making me crazy.
I am not having problems with the part of the code you have noted. It
works
fine. I need help with the other portions of the code.

When I have the below code added it thinks every record is a duplicate.
If
I take this out, it works fine. I think I have my ifs in the wrong place.

When I have a duplicate it promps and works to OK or delete
but
when the record is not a duplicate it still promps. When it is not a
duplicate how do I make it go directly to the getfilename and skpi the
prompt?

blnOK = Confirm("This schedule is a duplicate. Click 'Ok' to change input,
or 'Cancel' to delete record.")
Cancel = True

If Not blnOK Then
'set all required fields so record can be deleted.
Me![Photo] = "none"
Me![ReportDtID] = 1
Me![Page] = 999999999
Me.Undo
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
End If

--
deb


Douglas J. Steele said:
Assuming that a row is a duplicate if all 3 of ProjID, Page and
ReportDtID
are the same, I'd think you want:

If DCount("*", "tSchedImages", "[ProjID] = " & _
Me![ProjID] & " And [Page] = " & Me![Page] & _
" And [ReportDtID] = " & Me![ReportDtID]) > 0 Then



--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


deb said:
I am open to other suggestions...

I am trying to verivy if the record that I am inputting is not a
duplicate.
I want to make this verification when a button is clicked to open a
"find
file" feature.

I have the table set with the correct keys and it will verify when
exiting
the form but I need it to verify earlier so the user does not have to
complet
the whole form before they realize it is a duplicate.

Thanks in advance
--
deb


:

You're not comparing DCount("*", "tSchedImages", "[Page] = " &
Me![Page])
to anything. That means that as long as it's non-zero, it's going to
be
treated as True. Is that what you want?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


In my form...
This is associated with the button that calls the getfilename sub.

The below code is suppose to check 3 fields to see if it is a
duplicate
record. If it is a duplicate then bring up the msgbox to click OK to
go
back
to the record and make changes or Cancel to delete the record. If
the
record
is not a duplicate then it should move on to the getfilename.

The first If statement works great but when combined with the msgbox
stmt,
it thinks all records are duplicates.

If DCount("*", "tSchedImages", "[ProjID] = " & Me![ProjID]) > 0 And
DCount("*", "tSchedImages", "[Page] = " & Me![Page]) And DCount("*",
"tSchedImages", "[ReportDtID] = " & Me![ReportDtID]) <> 1 Then
blnOK = Confirm("This schedule is a duplicate. Click 'Ok' to change
input,
or 'Cancel' to delete record.")
Cancel = True

If Not blnOK Then
'set all required fields so record can be deleted.
Me![Photo] = "none"
Me![ReportDtID] = 1
Me![Page] = 999999999
Me.Undo
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
End If
Else
'Use the Office File Open dialog to get a file name to use
' as a picture.
getFileName

End If


Please help!!
 
D

deb

Any suggestions on how to make it work? I really need your help on this!!

When the user click on a button in a form it needs to test for duplicates.
If the 3 fields are duplicate prompt user to change record or delete record.
If they are not duplicates then call getfilename.
FYI...
The form's source - table tSchedImages has fields with default values...
Page default is 0
ReportDtID default is 1

There must be an easier way.
--
deb


Douglas J. Steele said:
It strikes me that you are having problems with the DCount code if the
"duplicate" prompt always appears, since that's what the code's supposed to
control!

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


deb said:
Thank you for your help!!! This is making me crazy.
I am not having problems with the part of the code you have noted. It
works
fine. I need help with the other portions of the code.

When I have the below code added it thinks every record is a duplicate.
If
I take this out, it works fine. I think I have my ifs in the wrong place.

When I have a duplicate it promps and works to OK or delete
but
when the record is not a duplicate it still promps. When it is not a
duplicate how do I make it go directly to the getfilename and skpi the
prompt?

blnOK = Confirm("This schedule is a duplicate. Click 'Ok' to change input,
or 'Cancel' to delete record.")
Cancel = True

If Not blnOK Then
'set all required fields so record can be deleted.
Me![Photo] = "none"
Me![ReportDtID] = 1
Me![Page] = 999999999
Me.Undo
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
End If

--
deb


Douglas J. Steele said:
Assuming that a row is a duplicate if all 3 of ProjID, Page and
ReportDtID
are the same, I'd think you want:

If DCount("*", "tSchedImages", "[ProjID] = " & _
Me![ProjID] & " And [Page] = " & Me![Page] & _
" And [ReportDtID] = " & Me![ReportDtID]) > 0 Then



--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I am open to other suggestions...

I am trying to verivy if the record that I am inputting is not a
duplicate.
I want to make this verification when a button is clicked to open a
"find
file" feature.

I have the table set with the correct keys and it will verify when
exiting
the form but I need it to verify earlier so the user does not have to
complet
the whole form before they realize it is a duplicate.

Thanks in advance
--
deb


:

You're not comparing DCount("*", "tSchedImages", "[Page] = " &
Me![Page])
to anything. That means that as long as it's non-zero, it's going to
be
treated as True. Is that what you want?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


In my form...
This is associated with the button that calls the getfilename sub.

The below code is suppose to check 3 fields to see if it is a
duplicate
record. If it is a duplicate then bring up the msgbox to click OK to
go
back
to the record and make changes or Cancel to delete the record. If
the
record
is not a duplicate then it should move on to the getfilename.

The first If statement works great but when combined with the msgbox
stmt,
it thinks all records are duplicates.

If DCount("*", "tSchedImages", "[ProjID] = " & Me![ProjID]) > 0 And
DCount("*", "tSchedImages", "[Page] = " & Me![Page]) And DCount("*",
"tSchedImages", "[ReportDtID] = " & Me![ReportDtID]) <> 1 Then
blnOK = Confirm("This schedule is a duplicate. Click 'Ok' to change
input,
or 'Cancel' to delete record.")
Cancel = True

If Not blnOK Then
'set all required fields so record can be deleted.
Me![Photo] = "none"
Me![ReportDtID] = 1
Me![Page] = 999999999
Me.Undo
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
End If
Else
'Use the Office File Open dialog to get a file name to use
' as a picture.
getFileName

End If


Please help!!
 
D

Douglas J. Steele

Did you try the amended DCount I suggested?

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


deb said:
Any suggestions on how to make it work? I really need your help on this!!

When the user click on a button in a form it needs to test for duplicates.
If the 3 fields are duplicate prompt user to change record or delete
record.
If they are not duplicates then call getfilename.
FYI...
The form's source - table tSchedImages has fields with default values...
Page default is 0
ReportDtID default is 1

There must be an easier way.
--
deb


Douglas J. Steele said:
It strikes me that you are having problems with the DCount code if the
"duplicate" prompt always appears, since that's what the code's supposed
to
control!

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


deb said:
Thank you for your help!!! This is making me crazy.
I am not having problems with the part of the code you have noted. It
works
fine. I need help with the other portions of the code.

When I have the below code added it thinks every record is a duplicate.
If
I take this out, it works fine. I think I have my ifs in the wrong
place.

When I have a duplicate it promps and works to OK or delete
but
when the record is not a duplicate it still promps. When it is not a
duplicate how do I make it go directly to the getfilename and skpi the
prompt?

blnOK = Confirm("This schedule is a duplicate. Click 'Ok' to change
input,
or 'Cancel' to delete record.")
Cancel = True

If Not blnOK Then
'set all required fields so record can be deleted.
Me![Photo] = "none"
Me![ReportDtID] = 1
Me![Page] = 999999999
Me.Undo
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
End If

--
deb


:

Assuming that a row is a duplicate if all 3 of ProjID, Page and
ReportDtID
are the same, I'd think you want:

If DCount("*", "tSchedImages", "[ProjID] = " & _
Me![ProjID] & " And [Page] = " & Me![Page] & _
" And [ReportDtID] = " & Me![ReportDtID]) > 0 Then



--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I am open to other suggestions...

I am trying to verivy if the record that I am inputting is not a
duplicate.
I want to make this verification when a button is clicked to open a
"find
file" feature.

I have the table set with the correct keys and it will verify when
exiting
the form but I need it to verify earlier so the user does not have
to
complet
the whole form before they realize it is a duplicate.

Thanks in advance
--
deb


:

You're not comparing DCount("*", "tSchedImages", "[Page] = " &
Me![Page])
to anything. That means that as long as it's non-zero, it's going
to
be
treated as True. Is that what you want?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


In my form...
This is associated with the button that calls the getfilename
sub.

The below code is suppose to check 3 fields to see if it is a
duplicate
record. If it is a duplicate then bring up the msgbox to click OK
to
go
back
to the record and make changes or Cancel to delete the record. If
the
record
is not a duplicate then it should move on to the getfilename.

The first If statement works great but when combined with the
msgbox
stmt,
it thinks all records are duplicates.

If DCount("*", "tSchedImages", "[ProjID] = " & Me![ProjID]) > 0
And
DCount("*", "tSchedImages", "[Page] = " & Me![Page]) And
DCount("*",
"tSchedImages", "[ReportDtID] = " & Me![ReportDtID]) <> 1 Then
blnOK = Confirm("This schedule is a duplicate. Click 'Ok' to
change
input,
or 'Cancel' to delete record.")
Cancel = True

If Not blnOK Then
'set all required fields so record can be deleted.
Me![Photo] = "none"
Me![ReportDtID] = 1
Me![Page] = 999999999
Me.Undo
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
End If
Else
'Use the Office File Open dialog to get a file name to use
' as a picture.
getFileName

End If


Please help!!
 
D

deb

At first glance I thought it was the sam as what I already had. MY BAD. I
did not notice the &.

I tried you code and of course it works like a dream.

I can go home now and enjoy my weekend, thanks to you!!!
Thank you again!!!
--
deb


Douglas J. Steele said:
Did you try the amended DCount I suggested?

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


deb said:
Any suggestions on how to make it work? I really need your help on this!!

When the user click on a button in a form it needs to test for duplicates.
If the 3 fields are duplicate prompt user to change record or delete
record.
If they are not duplicates then call getfilename.
FYI...
The form's source - table tSchedImages has fields with default values...
Page default is 0
ReportDtID default is 1

There must be an easier way.
--
deb


Douglas J. Steele said:
It strikes me that you are having problems with the DCount code if the
"duplicate" prompt always appears, since that's what the code's supposed
to
control!

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Thank you for your help!!! This is making me crazy.
I am not having problems with the part of the code you have noted. It
works
fine. I need help with the other portions of the code.

When I have the below code added it thinks every record is a duplicate.
If
I take this out, it works fine. I think I have my ifs in the wrong
place.

When I have a duplicate it promps and works to OK or delete
but
when the record is not a duplicate it still promps. When it is not a
duplicate how do I make it go directly to the getfilename and skpi the
prompt?

blnOK = Confirm("This schedule is a duplicate. Click 'Ok' to change
input,
or 'Cancel' to delete record.")
Cancel = True

If Not blnOK Then
'set all required fields so record can be deleted.
Me![Photo] = "none"
Me![ReportDtID] = 1
Me![Page] = 999999999
Me.Undo
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
End If

--
deb


:

Assuming that a row is a duplicate if all 3 of ProjID, Page and
ReportDtID
are the same, I'd think you want:

If DCount("*", "tSchedImages", "[ProjID] = " & _
Me![ProjID] & " And [Page] = " & Me![Page] & _
" And [ReportDtID] = " & Me![ReportDtID]) > 0 Then



--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I am open to other suggestions...

I am trying to verivy if the record that I am inputting is not a
duplicate.
I want to make this verification when a button is clicked to open a
"find
file" feature.

I have the table set with the correct keys and it will verify when
exiting
the form but I need it to verify earlier so the user does not have
to
complet
the whole form before they realize it is a duplicate.

Thanks in advance
--
deb


:

You're not comparing DCount("*", "tSchedImages", "[Page] = " &
Me![Page])
to anything. That means that as long as it's non-zero, it's going
to
be
treated as True. Is that what you want?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


In my form...
This is associated with the button that calls the getfilename
sub.

The below code is suppose to check 3 fields to see if it is a
duplicate
record. If it is a duplicate then bring up the msgbox to click OK
to
go
back
to the record and make changes or Cancel to delete the record. If
the
record
is not a duplicate then it should move on to the getfilename.

The first If statement works great but when combined with the
msgbox
stmt,
it thinks all records are duplicates.

If DCount("*", "tSchedImages", "[ProjID] = " & Me![ProjID]) > 0
And
DCount("*", "tSchedImages", "[Page] = " & Me![Page]) And
DCount("*",
"tSchedImages", "[ReportDtID] = " & Me![ReportDtID]) <> 1 Then
blnOK = Confirm("This schedule is a duplicate. Click 'Ok' to
change
input,
or 'Cancel' to delete record.")
Cancel = True

If Not blnOK Then
'set all required fields so record can be deleted.
Me![Photo] = "none"
Me![ReportDtID] = 1
Me![Page] = 999999999
Me.Undo
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
End If
Else
'Use the Office File Open dialog to get a file name to use
' as a picture.
getFileName

End If


Please help!!
 

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