Messagebox mayhem

clare_voiant

Board Regular
Joined
Mar 20, 2002
Messages
76
Hi,

I am still struggling with some VBA concepts so forgive my crappy coding.... i have adapted some coding to open a form on the right record to try to include a messagebox when the date field 'Copy_Agreement_to_accounts' is greater than 11/08/04 (UK).... and then open an alternative form.

So my question is, why doesnt it work. what happens is the following code will give the messagebox and then open the alternative form, but it does this regardless of what the date is.....

where am i going wrong?

thanks

Clare

On Error GoTo Err_cmdviewclaims_Click

Dim stDocName As String
Dim stDocName1 As String
Dim stLinkCriteria As String


stDocName = "frmClaims"
stDocName1 = "frmBDC"


stLinkCriteria = "[ID]=" & "'" & Me![LT number] & "'"

If Me.Copy_agreement_to_accounts < #11/8/2004# Then

MsgBox "This is a 2004 offer company. Opening BDC's Instead"

DoCmd.OpenForm stDocName1, , , stLinkCriteria
Else
DoCmd.OpenForm stDocName, , , stLinkCriteria

End If
Exit_cmdviewclaims_Click:
Exit Sub

Err_cmdviewclaims_Click:
MsgBox Err.Description
Resume Exit_cmdviewclaims_Click

End Sub
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
For a start you have the condition the wrong way round it should be >.

Secondly it's an American thing that's causing the problem.

Try typing 11 August 2004 between the #'s you should end up with #8/11/2004#. ie the date in American style.
 
Upvote 0

Forum statistics

Threads
1,221,805
Messages
6,162,074
Members
451,738
Latest member
gaseremad

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