Please check my code

kmclane

New Member
Joined
Apr 1, 2004
Messages
42
I can't Find any reference to tell me what I am doing wrong here. Can someone please advise. The error I get is "expected object" and it highlights the first "=", but gives me no clues what is wrong.
Thanks, Ken

Option Compare Database
Option Explicit
Dim sera As String

Private Sub Command40_Click()
If Forms![MultiQuery]![Era] = 1 Then Set sera = "Current"
Else: Set sera = "History"
End If
If Forms![MultiQuery]![QueryChoice] = (1) Then DoCmd.OpenQuery [sera] & "Vital", acViewNormal, acReadOnly
ElseIf Forms![MultiQuery]![QueryChoice] = (2) Then DoCmd.OpenQuery [sera] & "ARU", acViewNormal, acReadOnly
ElseIf Forms![MultiQuery]![QueryChoice] = (3) Then DoCmd.OpenQuery [sera] & "STL", acViewNormal, acReadOnly
End If
End Sub
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Thanks, that fixed it, plus I had to fix my Block IF formatting. Now I need to change the date format depending on which query I end up in, one uses MMDDYY and the other two use YYMMDD. Is there a way to take the value entered in short date format and manipulate it either way as needed?
Thanks, Ken
 
Upvote 0
Yes. If those are of Date/Time data type, you can use the Format function to display it however you want.
e.g.:
Format(YourDateField,"mm/dd/yy")
 
Upvote 0
They are date fields, and I do have them formatted as such, the problem is the date field they are checking against is MMDDYY in one table but is YYMMDD in two others. I am trying to let users run queries against any table without having to change the way they enter the date. Thanks, Ken
 
Upvote 0
To avoid date entry errors I usually use a form with a Calendar control. You can format a textbox to display the date as desired and use the calendar control to ensure that the correct date is entered. Using VBA you can set the control to appear when required, and disappear when it's not.
 
Upvote 0
The date entry is not the problem at all, I need to reformat the value after it is enter in two specific cases. The users are fine, it is the data in the table that is ****eyed. I need a way to take the value they enter and move the last two numbers to the front. I hope this clarifies, Thanks, Ken
 
Upvote 0

Forum statistics

Threads
1,221,674
Messages
6,161,215
Members
451,691
Latest member
fjaimes042510

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