Variable Not Being Passed to Form by Macro

mercredi 18 février 2015

APOLOGIES - POSTED IN ERROR.



The hyperlink/macro problem reported below is in fact working correctly and opening the form in the correct mode using the variable passed to it. We have just realised that the procedures called from the linked form a not working correctly (Null values being picked up). This is a separate problem and will be directed to the VBA forum.







We use a hyperlink in a form (list of yacht races) to run a macro event - the opening of a form (main form to manage a race) and pass a variable (race number) to the newly opened main form. This has been working for some time but we want to change the Window Mode of the form being opened from Dialog to Normal so that we can get scroll bars (the main race management form won't fit onto the screen of smaller PCs). This isn't working as the variable isn't passing to the new form. I am setting out below the macros NEW & OLD but I can't figure out why this isn't working. Help would be much appreciated:



OLD MACRO (open form in Window Mode = Dialog) This works well:

OnError

GOto Macro Name

Macro Name ErrorHandIer

If [Form].[Dirty] Then

RunMenuCommand

Command SaveRecord

End If

If IsNull([ID]) Then

/* Open the form to a new record if the current ID is Null

OpenForm

Form Name frmManageRace

View Form

Filter Name

Where Condition

Data Mode Add

Window Mode Dialog

Requery

Control Name

Else

/* Use a TempVar to pass a filter to the OpenForm action

SetTempVar

Name tmpVar1

Expression =[ID]

OpenForm

Form Name frmManageRace

View Form

Filter Name

Where Condition =[tblRace_ID]=[TempVars]![tmpVar1]

Data Mode Edit

Window Mode Dialog

RemoveTempVar

Name tmpVar1

RefreshRecord

End If



NEW MACRO (open form in Window Mode = Dialog) This drops the variable of yacht race:

OnError

GOto Macro Name

Macro Name ErrorHandIer

If [Form].[Dirty] Then

RunMenuCommand

Command SaveRecord

End If

If IsNull([ID]) Then

/* Open the form to a new record if the current ID is Null

OpenForm

Form Name frmManageRace

View Form

Filter Name

Where Condition

Data Mode Add

Window Mode Normal

Requery

Control Name

Else

/* Use a TempVar to pass a filter to the OpenForm action

SetTempVar

Name tmpVar1

Expression =[ID]

OpenForm

Form Name frmManageRace

View Form

Filter Name

Where Condition =[tblRace_ID]=[TempVars]![tmpVar1]

Data Mode Edit

Window Mode Normal

RemoveTempVar

Name tmpVar1

RefreshRecord

End If

Variable Not Being Passed to Form by Macro

0 commentaires:

Enregistrer un commentaire

Labels