Macros quit working (1 Viewer)

eMel

Registered User.
Local time
Yesterday, 23:49
Joined
Jun 23, 2014
Messages
62
My macros worked yesterday, now they don't. ???? They work in my other databases, though. Ideas?

And I need a suggestion for an And If scenario. If I update one field, the second databases macros work fine. If I update multiple fields, only the first instance writes to a table. Hence rather than Else If, I need something in the way of And If do this too.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 07:49
Joined
Jul 9, 2003
Messages
16,280
>>> My macros worked yesterday, now they don't. ????<<<

Create a new Macro... Does the new one work?
 

vbaInet

AWF VIP
Local time
Today, 07:49
Joined
Jan 22, 2010
Messages
26,374
And I need a suggestion for an And If scenario. If I update one field, the second databases macros work fine. If I update multiple fields, only the first instance writes to a table. Hence rather than Else If, I need something in the way of And If do this too.
You're better of writing code for this. The AND IF situation will totally depend on the scenario. Expand on this.
 

eMel

Registered User.
Local time
Yesterday, 23:49
Joined
Jun 23, 2014
Messages
62
I got the macros working. So far as 'And If' scenario, when a table field is changed, I want to write to an AuditTable. When one field is change, my macros work great. When two fields, in a record, are changed only the later is written. I need my macros to write both changes.
 

vbaInet

AWF VIP
Local time
Today, 07:49
Joined
Jan 22, 2010
Messages
26,374
I don't really use Macros but there's an inner IF block you can use. So to the left of the first IF click the plus '+' sign to expand it and enter your second IF condition there. That will equate to IF Condition AND IF Condition
 

eMel

Registered User.
Local time
Yesterday, 23:49
Joined
Jun 23, 2014
Messages
62
Thanks vbaInet. If you mean the 'Else If' I've tried that and it only writes one field change. ie: If I change the Last Name and the First Name, only the last change writes to a table. Or maybe there is something like a 'GOTO' command that I could put at the end of an 'If' statement.
 

vbaInet

AWF VIP
Local time
Today, 07:49
Joined
Jan 22, 2010
Messages
26,374
Ok, if you re-read my post then perhaps it will be more clear. Look at the first IF line, to the left of the word "IF" there's a button, press it to expand it and enter your condition that second IF that's inside the first IF. I believe that's equivalent to AND IF.
 

eMel

Registered User.
Local time
Yesterday, 23:49
Joined
Jun 23, 2014
Messages
62
I see the 'IF'. I see the '+'. I click the '+'. It opens and shows all my SetFields. At the bottom right, I see 'Add Else' and I see 'Add Else If'. I have used 'Else If''. When I change multiple fields, using 'Else If', only one change is written to the AuditTable. 'Else' means do instead.
 

vbaInet

AWF VIP
Local time
Today, 07:49
Joined
Jan 22, 2010
Messages
26,374
Ok, here's a diagram. Notice the pic

By the way I've noticed that when you reply you enter random text and go back and edit it. Is the website not working well for you?
 

Attachments

  • Expand If.png
    Expand If.png
    4.4 KB · Views: 232

eMel

Registered User.
Local time
Yesterday, 23:49
Joined
Jun 23, 2014
Messages
62
My work computer won't allow replies, so I type jibberish on my cell phone, and then edit on my desktop. Go figure.

Thanks for the image. I'm slow, I guess! Let me give it a shot.

Thanks!
 

vbaInet

AWF VIP
Local time
Today, 07:49
Joined
Jan 22, 2010
Messages
26,374
Haha ok! How about the "Go Advanced" button, have you tried that?
 

eMel

Registered User.
Local time
Yesterday, 23:49
Joined
Jun 23, 2014
Messages
62
Cell Phone -> Desktop! Not yet. I'll probably need you to hold my hand and point to it. I've tried the second 'If'' and when I make changes, the second if writes. The first on does not. It also doesn't work when I do it separately.

So I delete the 2nd 'If'..Now the first one doesn't work. :banghead:
 
Last edited:

eMel

Registered User.
Local time
Yesterday, 23:49
Joined
Jun 23, 2014
Messages
62
When I make two changes to a record, only the latter one writes to the AuditTable. For example, If I change the last name and then the first name, only the first name change is written to the AuditTable. I need both changes to write.
 
Last edited:

vbaInet

AWF VIP
Local time
Today, 07:49
Joined
Jan 22, 2010
Messages
26,374
I don't know your entire macro and I don't know how your macro relates to saving records.

Unhinge the macro and see if it works. If it does then it's nothing to do with the macro.
 

vbaInet

AWF VIP
Local time
Today, 07:49
Joined
Jan 22, 2010
Messages
26,374
It's not a technical term. Unhinge = remove

What does your macro do? And how does it relate to your records not being saved? I need to see.
 

eMel

Registered User.
Local time
Yesterday, 23:49
Joined
Jun 23, 2014
Messages
62
Everything else works fine whether the macro is there or not. The macro is what writes the record, so if it's not there it can't perform.
The macro performs a 'CreateRecord' on an AuditTable whenever my Customer table has a field that has been changed. This works great when I change one field. When I change two fields, in a record, only the latter changed is written to a table. I number these records with an autonumber sequence. ie. If the last changed is numbered 39 then obviously the next change comes out as 40, when I change one field, in a record. If I change two fields, then the auto number jumps by two. ie: 40 goes to 42, so I know the database is recognizing the change, but is not writing both changes to a table.
Table Format, if it helps:
InstanceID | DateTime | UserName | TableName | Action (Update) | RecordID | FieldName | OldValue | NewValue
 
Last edited:

Users who are viewing this thread

Top Bottom