Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automating a record based on day of week 1

Status
Not open for further replies.

Navo720

Technical User
May 25, 2004
4
US
Hello...This is my first posting. I would like to say thanks to everyone in advance for such a great site. I am very new to programming would like some help. I have two questions. First,I am working with two tables in Access 2000. One of these tables (table 1)is a lookup table with information for day of week (Sun, Mon, etc...)as field 1 and other data for field 2, 3 ,etc. I would like the other table (table 2)to pull up the fields based on the date that I enter. For example, if I typed 5/25/04 in a textbox in table 2, how do I get access to pull field 2, 3, etc... from table 1 for Tuesday's information. Second, how do I clear out a bounded textbox field when I exit a form. I tried setting the form's on exit procedure with field.text="" but that didn't seem to work.
Thanks for whatever assistance you can give!!
 
Hi,
Put an unbound textbox on the form (table 2). Controlsource= YourDateField
Format = dddd
This will display the day of the date entered in the date field.
Ok
Secondly
Put this code in the Enter Event of the new Textbox
Code:
Set DB = CurrentDb
rst = Recordset
Set rst = DB.OpenRecordset("Select [red]day[/red] from table1 where day= '" & Newtextbox.Text & "'")
'Pull information from table 1
text1 = rst.Fields("Textinfo1").Value
text1 = rst.Fields("Textinfo2").Value
Hope this help
Post back if you are unable to solve


Zameer Abdulla

 
I really appreciate your help. I tried this but I seem to be doing something wrong. I keep getting a debugging error. When I tried applying it to the database I'm working on, the error was on the set DB, so I tried it on a completely new blank test database. The debug error points to the set rst line.
As I said before I am completely new to programming. Could you also point me to a good book to learn programming from beginning to end. Everything I have looked at so far expected prior programming skills.
 
Provided [Table 1].[Field 1] is populated with the exact short day names in respect with your regional settings, you can try something like this (in the AfterUpdate event procedure of the date textbox):
If IsDate(Me![TextBoxDate]) Then
MsgBox DLookUp("[Field 2]", "[Table 1]", "[Field 1]='" & Format(Me![TextBoxDate], "ddd") & "'")
End If

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top