Results 1 to 2 of 2
Thread: goto record command (2000/xp)
2004-08-03, 23:22 #1
- Join Date
- Oct 2003
- Thanked 0 Times in 0 Posts
goto record command (2000/xp)
Have created a database from scratch and have created so far, three separate tables ie, studentid (primary key), enrolmentid (primary key) and visitid (primary key). They have relationships based off the studentid. I have been having problems when creating forms with buttons to open, close or whatever. For some reason the wizard is having problems - activex and ms access problems. However have decided to run a macro to do some of the basic functions such as open, close forms etc.
Main problem is if I am sitting in a particular record in form view and I want to open another form in regards to the current record, how do I set the macro to do just that. I am using the "goto" record command, but am having trouble using the "offset" option. <img src=/S/confused.gif border=0 alt=confused width=15 height=20> Please help me.
2004-08-03, 23:41 #2
- Join Date
- Mar 2002
- Thanked 29 Times in 29 Posts
Re: goto record command (2000/xp)
About the ActiveX problems etc.: see if the suggestions in <post#=340852>post 340852</post#> help.
I wouldn't use the GoToRecord action, but set the WhereCondition argument of the OpenForm action. I never use macros for this purpose, but VBA code. It would go like this:
- Put a command button on the student form. Let's say you name it cmdOpen.
- With the command button selected, activate the Event tab of the Properties window.
- Click in the On Click event.
- Select Event Procedure from the dropdown list.
- Click the ... to the right of the dropdown arrow.
- The Visual Basic Editor will be activated, and the first and last line of the event procedure will already be there:
Private Sub cmdOpen_Click()
- The insertion point will be in the blank line in between.
- Press the tab key, then type the following code:
DoCmd.OpenForm FormName:="frmOtherForm", WhereCondition:="StudentID = " & Me.StudentID
- Replace frmOtherForm by the name of the form to be opened.
- I have assumed that StudentID is a number field.
Post back if you have questions, or need more assistance.