Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / New Users / April 2005

Tip: Looking for answers? Try searching our database.

Code to go to a record in pop up form based on record in active fo

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kevin - 28 Apr 2005 15:30 GMT
Hi all,
can anyone help me. I am new to access programming. Can you give me the step
by step vb code (or macro design) in order to go straight to a record in a
pop up form based on a record within the current form.
I'm stuck.
Kind regards
Kevin.
Ed Warren - 28 Apr 2005 16:26 GMT
I 'borrowed' the following code from somewhere, sorry I don't recall where
but it allows you to sync two forms (move from one record in the first,
moves the record in the second)

in the code module:

Function IsLoaded(ByVal strFormName As String) As Boolean

' Returns True if the specified form is open in Form view or Datasheet view.

Const conObjStateClosed = 0

Const conDesignView = 0

If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed
Then

If Forms(strFormName).CurrentView <> conDesignView Then

IsLoaded = True

End If

End If

End Function

In 'FORM1' oncurrent event

Dim stDocName As String

Dim stLinkCriteria As String

stDocName = "Form2"

stLinkCriteria = "[LinkKey]=" & Me![LinkKey]

If (IsLoaded(stDocName) = True) Then

Forms!(stDocName).FilterOn = True

Forms!(stDocName).Filter = stLinkCriteria

End If

Now changing records in form1 changes the record in form2.

Another option is to use the 'button wizard'  when you put a new button on
the form it askes if you want to open a form, if so it asks if you want to
all records or specific records, you thell it what form you want to open and
what the matching  keys are and it builds the code for you in the
button_click event.  I then add a little code to the double click event to
open the associated form when the first form is double clicked

Call button1_onClick()

Ed Warren

> Hi all,
> can anyone help me. I am new to access programming. Can you give me the
[quoted text clipped - 4 lines]
> Kind regards
> Kevin.
Jason Rice - 28 Apr 2005 16:50 GMT
If you need to edit the record, you can create your popup form so that it is
based on the table containing the record you want.  You can then set an
event to run (either from a button on your first form, or when opening the
popup) to set the filter.

From The main Form:
DoCmd.OpenForm, "frmPopup"
Forms!frmPopup.Filter="some limiting text" - this is like the 'Where' clause
in a SQL query (i.e. "RecordID='Value'")
Forms!frmPopup.FilterOn = -1

Note:
There are other syntax methods you can use to refer to your popup form
You can use the reserved word "True" instead of "-1".  True=-1, False=0

HTH
Jason Rice

You can set the
> Hi all,
> can anyone help me. I am new to access programming. Can you give me the
[quoted text clipped - 4 lines]
> Kind regards
> Kevin.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.