Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2004
    Location
    San Diego
    Posts
    45

    Unanswered: Help with some code....

    What I need to do is check if the date is Friday, and write some data to a table. If the table already contains the Friday Date of the current week, then do nothing. I am not sure how to refer to the tables in the database within code. I have used access for a few other jobs, and have never had to do this. Here is what I have so far. Could someone help me out?

    Code:
    Private Sub Form_Open(Cancel As Integer)
    
        DoCmd.SetWarnings False
        
        DoCmd.OpenQuery ("PreParseGems"), , acReadOnly
        
        If Now() <> qryGetFridayDate.last_day Then
        Exit Sub
        Else
            If tblStoredRatios.FridayDate = Now() Then
            Exit Sub
            Else
                DoCmd.OpenQuery ("qryAppendRatios"), , acAdd
            End If
        End If
        
        DoCmd.SetWarnings True
        
    End Sub

  2. #2
    Join Date
    Jul 2004
    Posts
    125
    At a glance, where are you opening the qryGetFridayDate for a read? Also, how do you read the table tblStoredRatios? You are in the right direction but you have some more work to do, like getting your variables read before you can act on them.

  3. #3
    Join Date
    Mar 2004
    Location
    San Diego
    Posts
    45
    That is actually why I was posting. I admit that I am a dolt and that I don't refer/manipulate my tables and queries within the code. I have done okay so far, but I am not sure what the syntax is to read and refer to the tables in my db, or the queries for that matter. I feel kind of foolish that I am asking this, and I didn't have any luck doing a google search. I think my if then logic is great, but it is the nuts and bolts that I am missing.

    Please enlighten me.....


    Thanks!

  4. #4
    Join Date
    Jul 2004
    Posts
    125
    Two things: 1st ... Don't call yourself a "dolt". We are a community of the temporarily challenged, we need direction and that is why we are here. 2nd. Since seeing is believing - meaning both of us, if you want help, please upload a a zipped sample db in Access 2000 format and I will code it for you with explanations. Otherwise, I would be sitting here and composing for hours (and with errors) and still leave you frustrated with unanswered questions. Also, I would need a plain english explanation as to which record you wish to read (First? Last? Any?) and where to put it and where to show it? Table? form? etc.

    Basically, the idea is to collect the information from queries, tables etc. and then act on the collected infrormation. You have the right idea, and just missing some code. By the way, I use DAO (Data Access Objects) and I hope you would be comfortable with it. It is a precursor to the current vogue of using ADO, (Activex Data Objects) which is more web oriented. Otherwise, it's fast true and tried.

  5. #5
    Join Date
    Mar 2004
    Location
    San Diego
    Posts
    45
    Okay, here is a sample db. Here is what I need to happen.

    When the form is opened, I need to check if today is Friday. If it is Friday, then check the table for today's (Friday's) date. If the date is there, then exit, otherwise append the ratios to that table. If it is not Friday, then do nothing.

    Thank you so much for your help with this bad boy!

    One other thing that is peculiar....I have tried to no avail to get the ratios to show up as percentages, and now I have the wrong numbers appending to the ratio table. These are all showing up as 100% or 0%. But, they are formatted correctly. Any insights here?

    BTW
    I only jokingly refer to myself as a dolt. I consider myself pretty competent most of the time, really... but thanks for your understanding! ;-D
    Attached Files Attached Files

Posting Permissions

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