If Statement in a form

deb

Active Member
Joined
Feb 1, 2003
Messages
400
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!!
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Code:
portDtID]) <> 1 Then

.. this piece of code should be ...

Code:
portDtID]) >= 1 Then
.

Erik
 
Upvote 0

Forum statistics

Threads
1,224,813
Messages
6,181,117
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top