[AccessD] Am I missing something simple? - function in querycriteria

Kath Pelletti KP at sdsonline.net
Thu Mar 3 23:25:57 CST 2005


Yep - it is in a module - 

Kath
  ----- Original Message ----- 
  From: Jim Lawrence 
  To: 'Access Developers discussion and problem solving' 
  Sent: Friday, March 04, 2005 4:02 PM
  Subject: RE: [AccessD] Am I missing something simple? - function in querycriteria


  Hi Kath:

  Is the public function in a module and not the current form? Calling a
  function, from a query only works in a module.

  HTH
  Jim


  -----Original Message-----
  From: accessd-bounces at databaseadvisors.com
  [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Kath Pelletti
  Sent: Thursday, March 03, 2005 7:53 PM
  To: AccessD at databaseadvisors.com
  Subject: [AccessD] Am I missing something simple? - function in query
  criteria

  Hi all - 

  I am using a function in my query criteria. The function works and returns a
  value of  52275 (I can see that from the debug window).

  If I type in 52275 as the query criteria it rerurns a result, but if I use
  the function it doesn't. After much head banging I am looking for something
  basic I may be doing wrong. Any ideas? 

  Function is:

  Public Function GetTemplateld() As Long
  Dim strerrormsg As String
  Dim StrAccountno As String
  Dim IntRepCycleID As Integer
  'On Error GoTo Err_Handler

  If IsFormOpen("FrmClientDetails") = True Then
      GetTemplateld =
  [Forms]![FrmClientDetails]![FrmClientMarketValueHistorySubform]![TemplateID]

  ElseIf IsFormOpen("FrmReportCycleWorksheet_Master") = True Then
      GetTemplateld = [Forms]![FrmReportCycleWorksheet_Master]![TemplateID]
      
  ElseIf IsFormOpen("FrmMainMenu") = True Then
      StrAccountno = Forms![FrmMainMenu]![TxtReportingAccountNo]
      IntRepCycleID = Forms![FrmMainMenu]![TxtReportCycleID]
      gettemplateid = Nz(DLookup("[TemplateID]",
  "TblHistory_SubAccountTemplate", _
              "[AccountNo] = '" & StrAccountno & " '" & " And [reportcycleid]
  = " & IntRepCycleID))
  Else
      gettemplateid = 0
  End If

  Debug.Print gettemplateid

  Normal_exit:
      Exit Function
  Err_Handler:
      MsgBox "Error: [" & Err.Number & "]  " & IIf(Len(strerrormsg) > 0,
  strerrormsg, Err.Description), vbCritical, "Error Message"
      Resume Normal_exit
  End Function

  ______________________________________________
  Kath Pelletti
  Software Design & Solutions Pty Ltd.
  Ph: 9505-6714
  Fax: 9505-6430
  KP at SDSOnline.net
  -- 
  AccessD mailing list
  AccessD at databaseadvisors.com
  http://databaseadvisors.com/mailman/listinfo/accessd
  Website: http://www.databaseadvisors.com

  -- 
  AccessD mailing list
  AccessD at databaseadvisors.com
  http://databaseadvisors.com/mailman/listinfo/accessd
  Website: http://www.databaseadvisors.com


More information about the AccessD mailing list