By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,149 Members | 885 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,149 IT Pros & Developers. It's quick & easy.

Just a beginner

P: 4
I have a question about linking forms. Here is the scenerio: I am making a product cross matrix database for the company that I work for. I have a couple different forms that I am using to ultimately make a switchboard to find out information concerning different products. I have a form (Radar Multi Function) with a command button that links to another form (Antenna) when you click on it to give different antenna options and pricing. When I click on the button the form comes up but it does not match the record on the (radar multi function) from. For example if I was looking at record: 5 of 120 and I click on the button it brings up the (antenna) form but it is on record:1 of 120 so I have to manual go to record: 5 of 120 so they match up. I know there is a way to put a filter on the button to match the records or the ID which is what I am doing but can't seem to get it to work. I am just a beginner with Access 97 and I am trying to use the strLinkCriteria code to display the appropriate info and match up the records. This is what I have so far and it is not getting me anywhere. I have a ID that is the same in the table for every form. The ID is what I would like use as the link to have the forms line up. Any help would be most appreciated.


Private Sub Command3_Click()
On Error GoTo Err_Command3_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Antenna"
strLinkCriteria = [ID] = "Forms!Radar_Multi_Function! [ID]"

DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command3_Click:
Exit Sub

Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click

End Sub
Jun 7 '07 #1
Share this Question
Share on Google+
6 Replies


maxamis4
Expert 100+
P: 295
if ID is a string

Expand|Select|Wrap|Line Numbers
  1.     stDocName = "Antenna"
  2.     strLinkCriteria = "[ID]" = '" & Forms!Radar_Multi_Function! [ID] & "'
  3.  
if Id is an integer

Expand|Select|Wrap|Line Numbers
  1.     stDocName = "Antenna"
  2.     strLinkCriteria = "[ID]" = " & Forms!Radar_Multi_Function! [ID] & "
  3.  
Jun 8 '07 #2

P: 4
I appreciate the help, however, I tried your solution and we are not quite there yet. After inputing the code I saved and closed. I opened the form again and clicked the button and I recieved this message: Compile Error, Variable not defined. On the code page Private Sub Command_3Click() was highlighted in yellow and strLinkCriteria was highlighted in blue. This is what I have now: To answer your previous question the [ID] colunm in the table is an Autonumber. Thanks again.

Private Sub Command3_Click()
On Error GoTo Err_Command3_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Antenna"
strLinkCriteria = "[ID]" = " & Forms!Furuno_Radar_Multi_Function! [ID] & "
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command3_Click:
Exit Sub

Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click

End Sub
Jun 8 '07 #3

P: 4
I need a little more help

if ID is a string

Expand|Select|Wrap|Line Numbers
  1.     stDocName = "Antenna"
  2.     strLinkCriteria = "[ID]" = '" & Forms!Radar_Multi_Function! [ID] & "'
  3.  
if Id is an integer

Expand|Select|Wrap|Line Numbers
  1.     stDocName = "Antenna"
  2.     strLinkCriteria = "[ID]" = " & Forms!Radar_Multi_Function! [ID] & "
  3.  
Jun 8 '07 #4

maxamis4
Expert 100+
P: 295
Could you explain what exactly you need help with? The reason I put is That i am not sure if your id is a string which means it can hold letters or its an integer which means that it can only be a number
Jun 9 '07 #5

P: 4
Could you explain what exactly you need help with? The reason I put is That i am not sure if your id is a string which means it can hold letters or its an integer which means that it can only be a number

I believe the string is a number and not letters. In the design view in the table it says autonumber. I can't input any letters into that field. I am trying to link a form with another form and have the records be matched by ID. For example. If I was looking at item 6 of 120 and I Hit the buttom to show the other form. That form wouldn't come up as 6 of 120 it would start at record 1. So if I was to enter a value in that form it wouldn't change record 6 it would change record 1. I need it to change record 6.
Jun 11 '07 #6

JKing
Expert 100+
P: 1,206
Going to take a stab at this.
I believe the problem lies in your variable stLinkCriteria that is being used as the where statement.

If I understand correctly, what you want to do is take the ID from the first form and pass it to the second form so it opens with the related ID.

I think if you change your criteria to reflect the following you may have the results you are looking for.

stLinkCriteria = "[ID] = [Forms]![Form1]![ID]"

Where the first [ID] represents the ID field on the second form and [Forms]![Forms1]![ID] points to the ID of the original form.

Hope this helps.

JKing
Jun 14 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.