OnClick Macro opening Single Form

Ewiz

New member
Local time
Today, 00:08
Joined
Jan 9, 2015
Messages
5
First off let me apologize is this was already answered. I could not find this in the search.
A little background I am trying to design a macro to click to the selected record and show the current record selected. As of now I have it opening the first record form, but when I click on the other records and it goes to the first record only.
This is what I have.
(OnClick)
If
SetTempVar
Name TestCaseName_ID
Expression =[ID]
OnError
Go To Fail
Macro Name
OpenForm
Form Name Main
Where Condition =[ID]=[TempVars]![TestCaseName_ID]
Data Mode Edit
Window Mode Normal
RemoveTempVar
Name TestCaseName_ID
RefreshRecord
End If

Once I run this Macro I get error " The object doesn't contain he Automation object 'ID'"
stating - You tried to run a Visual Basic procedure to set a property or method for an object. However, the component doesn't make the proprty or method available for automation operations. Check the component's documentation for information on the properties and methods it makes available for Automation Operations.

Now, now of this does not make sense to me. To make sure that I was on track I pulled up a template and seen that I was good and I was. But it works the template but not for my database. I know that I am out of practice and it has been awhile, but there is no way that I forgot all fo this,m or that Access has changed so much. Can someone see where I am going wrong, or point me in the right direction. If more information is needed such as the relationships let me know. The database if really simple right now.

Thank you all for your time and effort!
E
 
I figured it out! Just incase a new user is looking for just this. Here is the code:
On Error GoTo Solution_Click_Err

If (Form.Dirty) Then
DoCmd.RunCommand acCmdSaveRecord
End If
If (IsNull(ID)) Then
On Error GoTo 0
DoCmd.OpenForm "Main", acNormal, "", "", acAdd, acDialog
DoCmd.Requery ""
Else
TempVars.Add "Main_ID", ID
On Error GoTo 0
DoCmd.OpenForm "Main", acNormal, "", "[ID]=[TempVars]![Main_ID]", acEdit, acDialog
TempVars.Remove "Main_ID"
DoCmd.RefreshRecord
End If


Solution_Click_Exit:
Exit Sub

Solution_Click_Err:
MsgBox Error$
Resume Solution_Click_Exit
:cool:
 
Last edited:

Users who are viewing this thread

Back
Top Bottom