Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2004
    Location
    Liverpool - UK
    Posts
    12

    Unanswered: Can anyone help a beginner please??

    I am a self taught beginner who is just beginning to try to understand writing modules in code – but I am struggling with the following;

    I have a table, ‘Transactions’ which contains the fields [AccountNo],[Date],[Receipts],[Payments],[Balance] and a form ‘Input_Transactions’ to input the data.

    I am trying to write an Event Procedure which, in effect, says – for the account number entered on the form- get the last balance from the table (ie from previous transactions) – add the receipts, subtract the payments – and store the answer in the field [Balance]

    I have tried for some considerable time to do this but my limited knowledge is clearly not up to the job! Can anybody help please??

  2. #2
    Join Date
    Jul 2004
    Location
    Inverurie
    Posts
    628
    email me and i'll give you a hand if you'd like.

  3. #3
    Join Date
    Sep 2004
    Location
    Greece
    Posts
    20
    hi the same here.

  4. #4
    Join Date
    Jul 2004
    Location
    Inverurie
    Posts
    628
    Quote Originally Posted by damv
    hi the same here.

    Same problem, or you are trying to learn how to write modules?

  5. #5
    Join Date
    Feb 2005
    Location
    The Hague, Netherlands
    Posts
    95
    With "store it in a field" you mean, store it in another field in the same table??

    To find one hit in a table, you can use 'findfirst' or 'findlast' (DOA-commands as I understood), in something like this:

    Code:
    Public Function FindTelnrFromUSRID(USRID As Long) As String
    
        Dim dbcurr As Database
        Set dbcurr = CurrentDb
        
        Dim rsRecords As Recordset
        Set rsRecords = dbcurr.OpenRecordset("tblmain", dbOpenDynaset)
    Above opens the table as Dynaset so you can now work with it

    Code:
        rsRecords.Findlast "USRID = " & USRID & " AND TELNR <> ''"
    Finds the last ROW in the table where USRID is a certain value AND TELNR is not entered


    Code:
        If Not rsRecords.NoMatch Then
            FindTelnrFromUSRID = rsRecords!TELNR.Value
            Else: FindTelnrFromUSRID = "unknown"
        End If
    If theres no hit, then return with 'unknown', otherwise read from that row the value stored in the field TELNR and return with that value.

    Code:
        Set rsRecords = Nothing
    
    End Function

    After this, you can display the result in a simple txtfield on your form, say txtShowResult:


    Code:
    txtShowResult = FindTelnrFromUSRID(Var)

    Hope it helps
    Last edited by avlan; 03-09-05 at 08:36.

Posting Permissions

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