One macro causing another Macro to not finish

Montez659

Well-known Member
Joined
May 4, 2005
Messages
918
Good morning (afternoon, evening) all!

I will try to explain this best I can, and will try to get a snapshot of what I am talking about here in a few after I figure out how to do it.

I have two forms, one a "list" and the other a details. One is essentially in datasheet view and the other individual records. There is a formula in the list so that if a user clicks on the the word "Open" it will apply a filter to the "details" form so that record will show. Clicking on "open" triggers an On Click event. Halfway through the Macro running as the code is called to open the form, the Macro halts to trigger the On Load event of the "details" form. All works well like this even though as I step through the code it seems like the rest of the "On Click" code doesn't trigger.

When it ceases to work properly is if I try to apply a filter to not show Archived records in the On Load event of the details form. If I do the simple code of ApplyFilter, the only thing that happens when the user clicks on "Open" is that it goes to record 1 instead of the correct record.

I will post the code or screenshots of the code here in a few.
 
Norie, I think I figured out an easy way to get what I was wanting without having to change up the UI (yay, no revolt!). I scrapped the exisiting Macro and simply did a DoCmd in VBA for the On Click event of the "list" form. I also scrapped the On Load Macro and replaced it with nothing. Since the form can only be opened by a button on the switchboard, I did some VBA on that button for another DoCmd. Here are the pieces of code: For the hyperlink on the "list" page:
Code:
DoCmd.OpenForm "Site Visit Details", acNormal, , "[visitID] = " & visitID
And for the opening of the filtered by archive from the switchboard:
Code:
DoCmd.OpenForm "Site Visit Details", acNormal, , "[archive] <>" & True
As always, thanks for your help!

P.S. I am still testing it to make sure that removing those Macro's doesn't mess with other functions, but the outlook looks good! :)
 
Upvote 0

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)
That's exactly the sort of code I meant. :)
 
Upvote 0
Forgot to ask a favour.

If you use "Not [archive]" for the criteria for the 2nd form does it work?

Just curious really.:)
 
Upvote 0
Actually, I ended up dropping that code anyways. :) After all that, I got a request to make the details page open to a new record which pretty much voided the need of loading up with the archive filter. So I included it as an option on the form itself.

But to answer your question, yes that works just fine.
 
Upvote 0
Montez

Thanks for testing.:)

So what do you have now? A button for a new record and a button for existing records?
 
Upvote 0
I added a button that will either apply the filter "<>[archive]" or remove the filter based on the user's selection. That's the easy idea of how it works, but I had to so some underhanded stuff (a hidden optionbutton) to make it blend in to the current UI. I still wiped out the other Macro and put it into VBA though. So much easier to do with one line of code as opposed to using the OpenArgs.
 
Upvote 0
Why do you need an option button?

How are you applying/removing the filter?

Couldn't you just use some sort of toggle?
Code:
Me.FilterOn = Not Me.FilterOn
 
Upvote 0
Yeah, I could have done it that way but I wanted it to integrate with the exisiting UI which used simple command buttons with the back style as transparent. I couldn't find that the toggle had a back style option, so I actually just use the commandbutton to trigger the hidden optionbutton(I guess I could have used a hidden toggle, but it is 'bout the same).
 
Upvote 0
I'm not suggestiing a toggle button, I'm suggesting you use that code with the existing button.:)
 
Upvote 0
What parameter are you checking then? Would it just be checking to see which filter is active? Also, is there a way to completely clear the filter? The only way that I found to do it was set the filter to "".
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,834
Members
452,947
Latest member
Gerry_F

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