Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

stLink Criteria

Status
Not open for further replies.

dixxy12

Technical User
Jun 18, 2007
45
CA
Hello,

Having trouble with the following:

I have a function "OpenFormEdit" that opens different forms, that gets called from different places.

Now i am trying to open a new "frmAddNewStockAssemblies"form in 'edit' mode and pass a link criteria to it and having trouble doing so.

here is the function:
Code:
Public Function OpenFormEdit(frmName As String)

    Dim frm As Form
    Dim stLinkCriteria As String
       
   DoCmd.OpenForm frmName, , , stLinkCriteria, acFormEdit
   DoEvents
   Set frm = Forms(frmName)
   
   If frmName = "frmJobs" Then
'   MsgBox "edit Mode" 'debug
        frm.JobNumber.SetFocus
        DoCmd.RunCommand acCmdFind
        frm.cmdNew.Visible = False
        frm.Text179.Value = 1
        frm.Label95.Caption = "Search Form"
        frm.CustomerType.Locked = True
        DoCmd.GoToRecord , , acFirst
      If frm.Text179 = 1 Then frm.cmdCancel.Enabled = True
   ElseIf frmName = "frmAddNewInventory" Then
        frm.Caption = "View Inventory"
        MsgBox "Inventory in Edit Mode", , "Debug Pop-up"
  [b] ElseIf frmName = "frmAddNewStockAssemblies" Then  'will use later
    [COLOR=blue]    stLinkCriteria = "[groupID]= " & Forms![frmPurchaseOrders]![frmTabs].Form![frmStockAssemblies].Form![groupID] & "'" [/color]
        frm.txtSupplier.SetFocus
        frm.cboSupplier.Visible = False [/b]
   ElseIf frmName = "FormY" Then  
      'Setup for FormY
      frm.TextboxName.Value = 101
   End If
   
   Set frm = Nothing
   
End Function
this code opens my form but those not link it to the right data...

this is what i use to open the form (callthe function)
Code:
Call OpenFormEdit(stDocName)

can this be done,

Thanks,
 
How are ya dixxy12 . . .

The Argument [blue]stLinkCriteria[/blue] has to occur before [blue]DoCmd.OpenForm[/blue] in order to be included during execution of the line. This prompts an independent [blue]If Then[/blue] statement as follows (note the single quote error in red [red]'[/red] in [blue]stLinkCriteria)[/blue]:
Code:
[blue]   Dim frm As Form
   Dim stLinkCriteria As String
   
   If frmName = "frmAddNewStockAssemblies" Then
      stLinkCriteria = "[groupID]= [red][b]'[/b][/red]" & Forms![frmPurchaseOrders]![frmTabs].Form![frmStockAssemblies].Form![groupID] & "'"
   End If
   
   DoCmd.OpenForm frmName, , , stLinkCriteria, acFormEdit
   DoEvents
   Set frm = Forms(frmName)[/blue]
The above modifies the on going [blue]If Then[/blue] statement for [blue]frmAddNewStockAssemblies[/blue] to the following:
Code:
[blue]   ElseIf frmName = "frmAddNewStockAssemblies" Then  'will use later
      frm.txtSupplier.SetFocus
      frm.cboSupplier.Visible = False[/blue]
[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
that darn single quote will get you everytime!!!!

thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top