Click on Form to Open other Form

  • Thread starter TotallyLost via AccessMonster.com
  • Start date
T

TotallyLost via AccessMonster.com

I have two forms and I really need to be open one from another.

Two Forms:
Main Form
Return Record

and I want to be able to click on the field in the Main Form called "RMA
Number" and it brings up the Return Record with that RMA and coorisponding
info. I have the RMA as my primary key and have tried a few different ways
and I've check each fields spelling multiple times and there all the same.

When I do the openform macro, it opens to the first record everytime, doesnt
matter which RMA number I click on.
[RMA Number]=Forms![Return Record]![RMA Number]

I also tried doing this is VB, and get an error in which it cant find a field.
my click command code is:


Private Sub RMA_Number_Click()
On Error GoTo Err_RMA_Number_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = [ReturnRecord]

stLinkCriteria = "[RMA_Number]=" & Forms![ReturnRecord]![RMA_Number]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_RMA_Number_Click:
Exit Sub

Err_RMA_Number_Click:
MsgBox Err.Description
Resume Exit_RMA_Number_Click

End Sub

Any help? Im new to access and am going crazy
 
S

Scott Lichtenberg

Which form is your main form and which form is the one you want to open with
a filter? Based on your code below, it looks like you are trying to open
the form "ReturnRecord". However you are passing in a filter
(stLinkCriteria) that is looking for the RMA Number from the form you are
trying to open.

stDocName = [ReturnRecord]
stLinkCriteria = "[RMA_Number]=" & Forms![ReturnRecord]![RMA_Number]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Your LinkCriteria should read something like "[RMA_Number] = " &
Forms![Main Form]![RMA_Number]

Hope this helps
 
B

bassstuf via AccessMonster.com

The main form is called "Main Return"

I Tried putting the info in and got the error
"Access cant find the field 'l' refered to in your expression"

What i Have is:

Private Sub RMA_Number_Click()
On Error GoTo Err_RMA_Number_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = [ReturnRecord]

stLinkCriteria = "[RMA_Number] = " & Forms![Main_Return]![RMA_Number]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_RMA_Number_Click:
Exit Sub

Err_RMA_Number_Click:
MsgBox Err.Description
Resume Exit_RMA_Number_Click

End Sub





Scott said:
Which form is your main form and which form is the one you want to open with
a filter? Based on your code below, it looks like you are trying to open
the form "ReturnRecord". However you are passing in a filter
(stLinkCriteria) that is looking for the RMA Number from the form you are
trying to open.

stDocName = [ReturnRecord]
stLinkCriteria = "[RMA_Number]=" & Forms![ReturnRecord]![RMA_Number]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Your LinkCriteria should read something like "[RMA_Number] = " &
Forms![Main Form]![RMA_Number]

Hope this helps
I have two forms and I really need to be open one from another.
[quoted text clipped - 37 lines]
Any help? Im new to access and am going crazy
 
J

Jeff Boyce

Forms are based on data. What data is feeding your [MainForm] and
[ReturnForm]? That is, what is the table structure, and how are your
tables/data related?

One option, depending on how your data is structured, might be to use a main
form/subform model. Selecting a record on the main form would allow the
subform to display related records. No need to pop up another form!

Regards

Jeff Boyce
Microsoft Office/Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top