|
#1
|
|||
|
|||
|
>>>>
'DoCmd.OpenForm "frmPlantingDetails", , , "PlantingID =" & Me!PlantingID <<<< Is that an actual ' before the DoCmd.... function? If that's actually there, you may want to take that out. >-----Original Message----- >I am trying to open a subform with a command button on the >main form. I used the wizard to get the open form code. >I then edited the code to link the forms with the common >field. What I have is this: >Private Sub cmdPlantingDetails_Click() >On Error GoTo Err_cmdPlantingDetails_Click > > Dim stDocName As String > Dim stLinkCriteria As String > > stDocName = "frmPlantingDetails" > stLinkCriteria = "PlantingID=" & Me.PlantingID > DoCmd.OpenForm(stDocName,,,stLinkCriteria) > > 'DoCmd.OpenForm "frmPlantingDetails", , , "PlantingID >=" & Me!PlantingID > >Exit_cmdPlantingDetails_Click: > Exit Sub > >Err_cmdPlantingDetails_Click: > MsgBox Err.Description > Resume Exit_cmdPlantingDetails_Click > >End Sub > >After DoCmd.OpenForm(stDocName,,,stLinkCriteria) >I get an error message saying "expected =". >When I add the "= " the prompt comes up showing OpenForm >help highlighting "form name" at the beginning. I >commented the 5 lines after "On Error Go To" and added >DoCmd.OpenForm "frmPlantingDetails", , , "PlantingID =" & >Me!PlantingID (this is commented now). This opened the >subform but didn't link the two forms. >The main form is named "frmPlantings" with "PlantingID" as >the primary key. The subform is >named "frmPlantingDetails" with "PlantingID" field as the >foreign key. I am sure this is something simple that I am >missing but I haven't been able to figure it out. Any >help is appreciated greatly. >Thanks. >Walter > >. > |
![]() |
| Bookmarks |
| Sponsored Links |
| Thread Tools | Search this Thread |
|
|
| Sponsored Links |