AUTOMATICALLY DISPLAY FULL RECORD

WILYWAYNE11

New member
Local time
Today, 01:26
Joined
Aug 27, 2022
Messages
20
I have downloaded the Contact database template and noticed that there is control button that allows you to open a record from list view to full view. I have copied the programing but I cannot find a way to get it work on other databases. If someone had knowledge on how to achieve this action, either trough a change on the database design or a macro, pls let me know.

:confused::confused::confused::confused::confused::confused::confused::confused::confused::confused:
 
What does "cannot find a way to get it work" mean? What did you try? Do you get error message, wrong result, nothing happens?

Should be able to achieve it by duplicating the arrangement in Contacts so apparently you must have done something different.

The alternative is VBA.

If you want to provide the problem db for analysis, follow instructions at bottom of my post.
 
What happened to your original thread?
 
I installed the contact database and the initial form that opens is:- "Contact list" clicking on the hyperlink in the left-hand column, the column named "Open" you are taken to another form called "Contact details" The text box displaying open is named "txtOpen" and contains the following control source which makes it display either open or new "=IIf(IsNull([ID]),"(New)","Open")"...

When you click on this text box, "txtOpen" it runs the control (Text Box) onClick macro which opens the form "Contact details"...

Most programmers here do not use macros! They are inferior to VBA, difficult to use, difficult to copy, difficult to publish. In other words it's difficult to answer the question "why does my macro not work" as few can read it. I have managed to extract the macro, don't ask me how! If anyone has got a simple method which extracts and formats a Macro properly, I would be glad to hear it.

I've answered your question in the negative. I don't recommend you continue with extracting macros etc from the contact sample database provided by Microsoft, you are heading for a hiding to nothing...

Your best approach is to use one of the tried and tested methods used by VBA programmers, one in particular, where you extract the currently selected row ID which is based on an autonumber/primary Key field. Pass this ID into the form you are opening to display the single record you've selected.


There are normally at least three different methods to do this, subject to each developers personal preference. I'm sure someone will post you an example.
 
Last edited:
. I have managed to extract the macro,

Here's The Macro:-

Code:
                                                                        Begin
                                                                            Action ="OnError"
                                                                            Argument ="0"
                                                                        End
                                                                        Begin
                                                                            Condition ="[Form].[Dirty]"
                                                                            Action ="RunCommand"
                                                                            Argument ="97"
                                                                        End
                                                                        Begin
                                                                            Condition
                                                                        ="[MacroError].[Number]<>0"
                                                                            Action ="MsgBox"
                                                                            Argument
                                                                        ="=[MacroError].[Description]"
                                                                            Argument ="-1"
                                                                            Argument ="0"
                                                                        End
                                                                        Begin
                                                                            Condition ="..."
                                                                            Action ="StopMacro"
                                                                        End
                                                                        Begin
                                                                            Action ="OnError"
                                                                            Argument ="2"
                                                                        End
                                                                        Begin
                                                                            Action ="OpenForm"
                                                                            Argument ="Contact Details"
                                                                            Argument ="0"
                                                                            Argument =""
                                                                            Argument ="=\"[ID]=\" &
                                                                        Nz([ID],0)"
                                                                            Argument ="-1"
                                                                            Argument ="3"
                                                                        End
                                                                        Begin
                                                                            Condition ="Not IsNull([ID])"
                                                                            Action ="SetTempVar"
                                                                            Argument ="CurrentID"
                                                                            Argument ="[ID]"
                                                                        End
                                                                        Begin
                                                                            Condition ="IsNull([ID])"
                                                                            Action ="SetTempVar"
                                                                            Argument ="CurrentID"
                                                                            Argument
                                                                        ="Nz(DMax(\"[ID]\",[Form].[Record
                                                                        Source]),0)"
                                                                        End
                                                                        Begin
                                                                            Action ="Requery"
                                                                        End
                                                                        Begin
                                                                            Action ="SearchForRecord"
                                                                            Argument ="2"
                                                                            Argument ="Contact List"
                                                                            Argument ="2"
                                                                            Argument ="=\"[ID]=\" &
                                                                        [TempVars]![CurrentID]"
                                                                        End
                                                                        Begin
                                                                            Action ="RemoveTempVar"
                                                                            Argument ="CurrentID"
                                                                        End
                                                                        Begin
                                                                            Comment ="_AXL:<?xml
                                                                        version=\"1.0\" encoding=\"UTF-
                                                                        16\"
                                                                        standalone=\"no\"?>\015\012<Us
                                                                        erI"

C:\ATH\Backup\Forum Answers\AUTOMATICALLY DISPLAY FULL                                     10 September 2022
RECORD\Database5.accdb

Form: Contact List                                                                                  Page: 64
o:                        "nterfaceMacro
                  For=\"txtOpen\"
                  xmlns=\"http://schemas.microsoft
                  .com/office/access"

                  "services/2009/11/application\"><
                  Statements><Action
                  Name=\"OnError\"/><Conditiona"

                  "lBlock><If><Condition>[Form].[D"
                  End
                  Begin
                      Comment
                  ="_AXL:irty]</Condition><Statem
                  ents><Action
                  Name=\"SaveRecord\"/></Statem
                  ents></If"

                  "></ConditionalBlock><Conditional
                  Block><If><Condition>[MacroErro
                  r].[Number]&lt;&g"

                  "t;0</Condition><Statements><Ac
                  tion
                  Name=\"MessageBox\"><Argume
                  nt Name=\"Message\""
                          ">=[MacroError].[De"
                  End
                  Begin
                      Comment
                  ="_AXL:scription]</Argument></
                  Action><Action
                  Name=\"StopMacro\"/></Stateme
                  nts></If"

                  "></ConditionalBlock><Action
                  Name=\"OnError\"><Argument
                  Name=\"Goto\">Fail</Argum"
                          "ent></Action><Action
                  Name=\"OpenForm\"><Argument
                  Name=\"FormName\">Contact
                  Detai"
                          "ls</Argument><Argument "
                  End
                  Begin
                      Comment
                  ="_AXL:Name=\"WhereCondition\
                  ">=\"[ID]=\" &amp;
                  Nz([ID],0)</Argument><Argument
                   Nam"

                  "e=\"WindowMode\">Dialog</Arg
                  ument></Action><ConditionalBloc
                  k><If><Condition>Not "

                  "IsNull([ID])</Condition><Stateme
                  nts><Action
                  Name=\"SetTempVar\"><Argume
                  nt Name=\""
                          "Name\">CurrentID</Argu"
                  End
                  Begin
                      Comment
                  ="_AXL:ment><Argument
                  Name=\"Expression\">[ID]</Argu
                  ment></Action></Statements></I"

                  "f></ConditionalBlock><Condition
                  alBlock><If><Condition>IsNull([ID]
                  )</Condition><S"
                          "tatements><Action
                  Name=\"SetTempVar\"><Argume
                  nt
 
There is an option on the ribbon that lets you extract the embedded macros of a form and convert them to VBA. I should warn you though that the converted macros may have errors in them so text carefully. The conversion isn't perfect.
 
There is an option on the ribbon that lets you extract the embedded macros of a form and convert them to VBA

I covered converting macros to VBA in a YouTube video a while back, here's the video:-

 
I should warn you though that the converted macros may have errors in them

I discovered one such error when converting a Macro to VBA code. You may have to include the “Value” Property for your text box or combo box (whichever control the the macro is associated with) – this seems a bit odd to a seasoned Microsoft Access programmer because the value property is normally a default.

More Info Here:-

 

Users who are viewing this thread

Back
Top Bottom