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 / Forms / May 2008

Tip: Looking for answers? Try searching our database.

Goto Related record

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
IKMD66 - 14 May 2008 16:22 GMT
Hi,

I am new to forms and macro's etc so apologies in advance if there is a
simple solution to this.

I have a basic requirement where a form shows a related record number e.g.  
a students record displays the ID of a related student - in my case this
refers to the primary record where aditional details are stored - address,
parents / guardians etc. I want to place a button on a form that will allow
the user to click the button to jump to the related record.

Any assistance would be greatly appreciated.

Thanks in advance.
Kirk
Golfinray - 14 May 2008 16:30 GMT
A command button might work for you. Use the command button wizard for goto
record. If not you can use a combo box for a filter to find records. Use the
combo box wizard to create the combo and let it use the field name for your
lookup. Then right click on the combo, go to properties and then events. In
the afterupdate event start the code builder and type:
Me.filter = "[yourfieldname] = """ & Me.combo# & """"
Me.filteron=true

> Hi,
>
[quoted text clipped - 11 lines]
> Thanks in advance.
> Kirk
IKMD66 - 14 May 2008 17:46 GMT
Hi,

Thanks for your reply. I already have a go to (combo box) on the header of
the form - where the user can select the record and the form jumps to the
record. The issue I am trying to solve is - within a record there may already
be maintained a related record number I require a button to be placed beside
the related record number field that will allow the user simply to press the
button and jump to the related record (without having to type anything).

Further assistance is appreciiated.

Regards,
Kirk

> A command button might work for you. Use the command button wizard for goto
> record. If not you can use a combo box for a filter to find records. Use the
[quoted text clipped - 19 lines]
> > Thanks in advance.
> > Kirk
Beetle - 14 May 2008 18:11 GMT
When you say "jump to the related record" do you mean you're trying to
open another form to show additional info for that record ID? If so, you
can use the OpenArgs property of the OpenForm method.

In the On Click event of your command button in the first form put code like;

DoCmd.OpenForm "YourOtherForm", , , , , , "[RecordID]=" & Me.RecordID

(make sure to use the correct number of commas)

Then in the Open event of your other form you would put:

If Not IsNull (Me.OpenArgs) Then
 Me.Filter = Me.OpenArgs
 Me.FilterOn = True
End If
Signature

_________

Sean Bailey

> Hi,
>
[quoted text clipped - 33 lines]
> > > Thanks in advance.
> > > Kirk
IKMD66 - 14 May 2008 18:47 GMT
Hi,

Thansk foryour response.

Yes I do mean that it should open the (same) form but for the related
record. I will try what you suggest.

Regards,
Kirk

> When you say "jump to the related record" do you mean you're trying to
> open another form to show additional info for that record ID? If so, you
[quoted text clipped - 50 lines]
> > > > Thanks in advance.
> > > > Kirk
Beetle - 14 May 2008 23:00 GMT
The method I described is to open a differnet form based on some criteria.
However, I now suspect that you are just trying to move to a different
record on the same form, in which case my previous suggestion will not
work. If you are just trying to move to a different record on the same form,
then post back.
Signature

_________

Sean Bailey

> Hi,
>
[quoted text clipped - 60 lines]
> > > > > Thanks in advance.
> > > > > Kirk
IKMD66 - 15 May 2008 09:32 GMT
Hi Sean,

Yes I am just trying to move to a different record on the same form e.g when
I view client record 25, recorded within this record is the related client ID
10. I want to place a button beside this field that allows me to go to record
10.

Thanks again.

Regards,
Kirk

> The method I described is to open a differnet form based on some criteria.
> However, I now suspect that you are just trying to move to a different
[quoted text clipped - 66 lines]
> > > > > > Thanks in advance.
> > > > > > Kirk
Beetle - 15 May 2008 17:38 GMT
OK, so let's suppose you have a field called ClientID that is the primary key
for each client, and another field called RelatedClient that holds the
ClientID
number for some other client, each with an associated text box control on
your form. All you should need is some code like this in the On Click event
of your button;

Private Sub cmdYourButton_Click()

 With Me.RecordsetClone
    .FindFirst "[ClientID]=" & Me![RelatedClient]
    If Not .NoMatch Then
      Me.Bookmark = .Bookmark
    End If
 End With

End Sub

The above code assumes that ClientID and RelatedClient are integer values.
If they are text, then you will need to add qoutes in the code.
Signature

_________

Sean Bailey

> Hi Sean,
>
[quoted text clipped - 78 lines]
> > > > > > > Thanks in advance.
> > > > > > > Kirk
IKMD66 - 15 May 2008 19:42 GMT
Sean - You're a star.

Many thanks for your assitance - your logic provides exactly what is required.

Best Regards,
Kirk

> OK, so let's suppose you have a field called ClientID that is the primary key
> for each client, and another field called RelatedClient that holds the
[quoted text clipped - 99 lines]
> > > > > > > > Thanks in advance.
> > > > > > > > Kirk
IKMD66 - 15 May 2008 19:53 GMT
Sean,

If I may ask one more question. How do I prevent the runtime error "(3077)
syntax error (missing operator) in expression", if the button ie pressed when
no related record is maintained - in this case I do not want anything to
happen - simply, perhaps a message stating "Related Client not maintained."

I have detailed the programming below.

Private Sub GOTO_Click()
With Me.RecordsetClone
.FindFirst "[Client ID]=" & Me![Related (Primary) Client]
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End With
End Sub

Thanks again.
Kirk

> OK, so let's suppose you have a field called ClientID that is the primary key
> for each client, and another field called RelatedClient that holds the
[quoted text clipped - 99 lines]
> > > > > > > > Thanks in advance.
> > > > > > > > Kirk
IKMD66 - 15 May 2008 21:29 GMT
Sean,

No need to review. I found another post that let me check if the field is
null.

Thanks again.

Kirk

> Sean,
>
[quoted text clipped - 120 lines]
> > > > > > > > > Thanks in advance.
> > > > > > > > > Kirk
 
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.