Appearing text boxes and Date diff

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

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
 
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.
 

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
 
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"
 

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
 

Attachments

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

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 807,865 other people just like you!

Latest posts

Members online

Top