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.