Results 1 to 6 of 6
  1. #1
    Star Lounger
    Join Date
    Mar 2002
    Location
    Haaltert, Belgium
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I want to make a module, because the code in it wil be used often.
    This is the code:
    Code:
    Public Function TellenRecordsPanelen()
    Dim TellenRecords As Integer
    Dim strSQL As String
    Set db = CurrentDb
    strSQL = "select count(*) as recordteller from tblprojectdeurpanelen where lnkidprojectdeurpanelen = " & Forms!frmproject.ProjectHiddenDeuren.Form.Idprojectdeur
    Set rs = db.OpenRecordset(strSQL)
    
    TellenRecords = rs("recordteller")
    'MsgBox TellenRecords
    If IsNull(TellenRecords) Or TellenRecords = "0" Then
      Forms!frmproject.ProjectHiddenDeuren.Form.ProjecthiddenDeurenPanelen.Form.SourceOb
    ject = ""
      Forms!frmproject.ProjectHiddenDeuren.Form.cmdPanelen.Enabled = True
      Forms!frmproject.ProjectHiddenDeuren.Form.cmdPanelenHerBereken.Enabled = False
    Else
      Forms!frmproject.ProjectHiddenDeuren.Form.ProjecthiddenDeurenPanelen.Form.SourceOb
    ject = "subfrmprojecthiddendeurenpanelen"
      Forms!frmproject.ProjectHiddenDeuren.Form.ProjecthiddenDeurenPanelen.Form.SamenArt = Forms!frmproject.ProjectHiddenDeuren.Form.selSamenArt
     Forms!frmproject.ProjectHiddenDeuren.Form.ProjecthiddenDeurenPanelen.Form.NisBr = (DLookup("[nisbreedte]", "tblproject", "[idproject] = lnkidprojectdeur"))
      Forms!frmproject.ProjectHiddenDeuren.Form.ProjecthiddenDeurenPanelen.Form.DeurAant
    al = (DLookup("[aantaldeuren]", "tblproject", "[idproject] = lnkidprojectdeur"))
      Forms!frmproject.ProjectHiddenDeuren.Form.cmdPanelen.Enabled = False
      Forms!frmproject.ProjectHiddenDeuren.Form.cmdPanelenHerBereken.Enabled = True
      Forms!frmproject.ProjectHiddenDeuren.Form.ProjecthiddenDeurenPanelen.Form.AllowAdd
    itions = False
      Forms!frmproject.ProjectHiddenDeuren.Form.ProjecthiddenDeurenPanelen.Form.AllowEdi
    ts = True
    End If
    rs.Close
    db.Close
    End Function
    The error is on the line:
    strSQL = "select count(*) as recordteller from tblprojectdeurpanelen where lnkidprojectdeurpanelen = " & Forms!frmproject.ProjectHiddenDeuren.Form.Idprojec tdeur

    And the error message is:
    error 2465 tijdens uitvoering: door de toepassing of door object gedfineerde fout.

    I don't know how to translate this error, I work with a dutch versoin.

    Can someone help me please?

    Kind regards,
    Nancy

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    I don't read dutch, and the google translator is not much help, but..

    Is the problem that you have not declared rs and db as variables anywhere?
    Dim db as DAO.database
    Dim rs as DAO.recordset

    To find the number of records you don't need a recordset.

    You could use
    Dim lngcount as long
    Dim strwhere as string
    strwhere = "lnkidprojectdeurpanelen = " & Forms!frmproject.ProjectHiddenDeuren.Form.Idprojec tdeur"
    lngcount = dcount("*","tblprojectdeurpanelen",strwhere)
    if lngcount > 0 etc
    Regards
    John



  3. #3
    Star Lounger
    Join Date
    Mar 2002
    Location
    Haaltert, Belgium
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Now I get error 2471 tijdens uitvoeren (while execute)
    the expression queryparamter that you have given has caused folling error
    the line is= strwhere = "lnkidprojectdeurpanelen = " & Forms!frmproject.ProjectHiddenDeuren.Form.Idprojec tdeur"

    Kind regards

  4. #4
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    When are you running this function?

    Is frmProject open at the time?
    Has the Source Object for ProjectHiddenDeuren been set at the time?

    In the earlier version of this I have, ProjectHiddenDeuren is called frmProjectHiddenDeuren. Have you renamed it? or is this the cause of the error?
    Regards
    John



  5. #5
    Star Lounger
    Join Date
    Mar 2002
    Location
    Haaltert, Belgium
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hello,
    frmproject is open a the time when this function runs.
    It is running in the subform projecthiddendeuren.
    Yes I did rename is, and the same is correct. The subform as object is projecthiddendeuren and the form itself is named subfrmrojecthiddendeuren.
    frmproject aswel as projecthiddendeuren is open at the time of running of the function

    grts

  6. #6
    Star Lounger
    Join Date
    Mar 2002
    Location
    Haaltert, Belgium
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm sorry, I did find the error myself.
    I had forgotten a subform :-(

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •