1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Appearing text boxes and Date diff

Discussion in 'Business Applications' started by rev_ollie, Sep 28, 2008.

Thread Status:
Not open for further replies.
Advertisement
  1. rev_ollie

    rev_ollie Thread Starter

    Joined:
    Aug 28, 2008
    Messages:
    36
    Hi everyone

    Im trying to learn a load of stuff in access to get some practice in for when i find my project out next year and decided to make a hotel system.

    Im looking at the moment at a few barriers i hope you can help me with

    Firstly i have a text box called txt (origional or what :p) and a check box called check.
    Im sure this has been asked before but i cant get it to work. I would like the check box to make the text box appear when ticked so when there is no value eg no tick in check then txt is invisible.
    At the moment i have this:

    Private Sub check_Click()
    If check.Value = 1 Then
    txt.Visible = True
    Else
    txt.Visible = False
    End If
    End Sub

    It makes the text box dissapear but when i go to click it again it does nothing. I though i could add another IF statment to then say if there was

    check.Value = 0
    txt.Visible=False

    But id doesnt work so can you help me on this one.

    Also whats the best validation method to use to stop people booking the day before. Eg the date now is the 28 Sept 08 how can i stop someone booking a room for the 27 sept 08? Will i just use a date diff function to stop it. the field for that is just called date.

    Thanks any help would be great :D
     
  2. MRdNk

    MRdNk

    Joined:
    Apr 7, 2007
    Messages:
    439
    Hi rev_ollie
    Firstly welcome to the forums.

    Next, the solutions.

    Problem 1:
    Use True and False, for your checkbox value:
    Code:
    Private Sub check_Click()
        If check.Value = True Then
            txt.Visible = True
        Else
            txt.Visible = False
        End If
    End Sub
    

    Problem 2:
    txt.Value < Date -- "<" is less than; and "Date" is today's date.
    Code:
    Private Sub txt_LostFocus()
        If txt.Value < Date Then
            txt.BackColor = 255 'Red
        Else
            txt.BackColor = 16777215 'Standard colour
        End If
    End Sub
    
    This uses lostfocus, ie. after a user has updated this txtbox, and tabbed out of it, then run event procedure.
    I've also made it change the background colour of the txtbox to red if its before today, but you can replace this with whatever you like.date.
     
  3. rev_ollie

    rev_ollie Thread Starter

    Joined:
    Aug 28, 2008
    Messages:
    36
    Hi MRdnk

    Thanks so much for the solution to part one. It work great exactly what i want it to do. Brilliant :D

    As for the second part it looks right but just to be sure where is the best place ot put it. Should i just do it under code of should i add it as an event procedure?

    Thanks again :D
     
  4. MRdNk

    MRdNk

    Joined:
    Apr 7, 2007
    Messages:
    439
    Add it as an event procedure, I have one little revision and that would be use it under the "After Update", instead of "Lost Focus"
     
  5. rev_ollie

    rev_ollie Thread Starter

    Joined:
    Aug 28, 2008
    Messages:
    36
    Hi again
    Ive now moved on with the booking system the last on anyway and ive found out there was an incorrect realtionship in the system so ive started again.
    Ive been looking into a different way of booking but i cant seem to get it to work.
    The idea is the query will look for the appropriate fields and then thats linked to the form to book but:
    1 there is a problem with query_previouse_booking something about and aggregate function

    2 now if that was to work how could i get the overall thing to book?. im guessing it would be some form of code or control linked to a button that would save the file in a table ready to book?

    any help would be great :D.

    PS i have attached it to the post to have a look at its zipped because it wont allow access files. I will change the format from 2003 if required
     

    Attached Files:

  6. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/754065

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice