473,396 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

open form after checking system date

Hi there and happy new year to all of you.
I've been reading the thread "Auto Date in form "pages" from 'frys' in the topics and his/her problem is similar though not identical to mine.
Here is my database structure which works, crudely, but I'd like to re-fine it, if possible, so feel free to give your 2-pence on my design effort

My 'journal' is actually a time-table for an educational establishment. It relates to my lessons over the week, Mo-Fr, so there will never be a need to have dates relating to a Saturday/Sunday and there will also be substantial gaps in the dates during holidays.

For this reason, I have decided to enter the dates needed manually into a tbl.dates, from which my frm.planner gets its dates.

At present, I have sorted the query that feeds frm.planner in descending order, which means the last entered date will show up first when opening frm.planner.

Here is the thing I'd like to refine:
When planning ahead over the next week or so, I'll be using dates from tbl.dates that are in the future and so when opening frm.planner, it opens at a date that is yet to come. This means, I have to scroll backwards, sometimes quite a bit, depending on how much 'forward planning' I've done.

It's this 'back-scrolling' I'd like to eliminate if possible by putting in some code somwhere that compares the system date to the dates in tbl.dates to see if there is a match and then opens frm.planner on the matching date.

Any ideas anybody?
Thanks for reading
Jan 2 '09 #1
5 1626
missinglinq
3,532 Expert 2GB
Place this code in your frmPlanner. If a record exists with the current date, it'll open to that record, otherwise it'll open as usual, in your case to the latest date entered.

Where txtYourDate is the control that holds the date:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.   Me.txtYourDate.SetFocus
  3.   DoCmd.FindRecord Date
  4. End Sub
Welcome to Bytes!

Linq ;0)>
Jan 3 '09 #2
Hi there 'linq' and thanks for the reply.
tried it out straight away but I must be doing something wrong.
I was actually looking for the bit of code that opens the form in the first place but couldn't find it. I'm sure it must be there somewhere, else the form wouldn't open, or would it?
the from's name is 'Lessonplans' and this is the code attached to it so far:
================================================== =====
Private Sub Form_lessonplans_load()
Me.Date.SetFocus------------------------------------------- thanks, again, for the tip
DoCmd.FindRecord Date----------------------------------- wasn't quite sure where
End Sub -----------------------------------------------------------exactly to put it, so I put it at
-------------------------------------------------------------------------the very beginning.
I'm sure that
if I could find the code
that opens the form in
the first place, and inserted
the relevant bits there,
then it would work,
but those,
perhaps,
are the hopes of
an amateur enthusiast.
---------------------------------------------------------------------------------------------------------------
Private Sub Macro_Update_Click()
On Error GoTo Err_Macro_Update_Click

Dim stDocName As String

stDocName = "Update"----------------- ----------------------------this is a command-
DoCmd.RunMacro stDocName ----------------------------------- button on the form
--------------------------------------------------------------------------------- that lets me add a
Exit_Macro_Update_Click:---------------------------------------------- a new date straight
Exit Sub-------------------------------------------------------------------- form the form, rather
------------------------------------------------------------------------------------ than having to go to
Err_Macro_Update_Click:----------------------------------------------- tbl.dates first.
-------------------------------------------------------------------------------------It's not my code
MsgBox Err.Description----------------------------------------------access did that auto-
Resume Exit_Macro_Update_Click------------------------------matically

End Sub
---------------------------------------------------------------------------------------------------------------
Private Sub cmd_open_frm_academicMonitoring_Click()
On Error GoTo Err_cmd_open_frm_academicMonitoring_Click

Dim stDocName As String-----------------------------------------------command
Dim stLinkCriteria As String--------------------------------------------- button opens a
------------------------------------------------------------------------------------------subform to
stDocName = "Academic-Monitoring"-------------------------------record academic
DoCmd.OpenForm stDocName, , , stLinkCriteria--------------- achievements

Exit_cmd_open_frm_academicMonitoring_Cli:
Exit Sub

Err_cmd_open_frm_academicMonitoring_Click:
MsgBox Err.Description
Resume Exit_cmd_open_frm_academicMonitoring_Cli

End Sub
----------------------------------------------------------------------------------------------------------------
Private Sub rqry_wbw_assignments_Click()
On Error GoTo Err_rqry_wbw_assignments_Click

Dim stDocName As String

stDocName = "WBWAssignments"
DoCmd.OpenQuery stDocName, acNormal, acEdit

Exit_rqry_wbw_assignments_Click:
Exit Sub ---------------------------------------------------------------------this last lot opens
------------------------------------------------------------------------------------- a form to see if
Err_rqry_wbw_assignments_Click:------------------------------------ previously used
MsgBox Err.Description------------------------------------------------ assignments are
Resume Exit_rqry_wbw_assignments_Click------------------- of any use for the
--------------------------------------------------------------------------------------- current day; the
End Sub -------------------------------------------------------------------------decision as to
whether or not
they are useful is
taken by me, not
the computer :):)

================================================== =======
Jan 3 '09 #3
missinglinq
3,532 Expert 2GB
You need to place the code, exactly as I posted it, in the code module behind your planner form! Do not change Form_Load to Form_lessonplans_load!

The only thing you need to do, as I indicated before, is to replace txtYourDate with the actual of your control that holds your date. If your modification

Me.Date.SetFocus

means that you've actually named your tetxbox Date, you need to change this to something else. Date is a reserved word in Access, and using it as the name of a textbox or field is going to cause major problems! The change can be minor, such as simply using txtDate instead of Date.

Linq ;0)>
Jan 3 '09 #4
Fantastic!!! it works!!! Fantastic!!!
Thank you for the tip about reserved access words. my next step will be to find a list of all of them, so I don't use them to name tbl.fields. It took almost 20 minutes to change them all - the 'date' field is used in a number of other forms and reports as well - and re-set the links between the main-forms and subforms.
Thanks again:):):):):):)
Jan 3 '09 #5
missinglinq
3,532 Expert 2GB
Glad you got it working! Here's a link to a list of Reserved Words for the various versions of Access:

Reserved keywords in Microsoft Access 97, 2002, 2002 and 2003 | Database Solutions for Microsoft Access | databasedev.co.uk

Linq ;0)>
Jan 3 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Job Lot | last post by:
I have requirement where client has to call us to get a key to access a particular form. Secondly, I want the code to be valid for a day. Can some guide me in right direction to implement this...
1
by: ST | last post by:
This is my other error when I click on Immunoflourescence. I believe this is related to the other error I just posted (Input string was not in a correct format.) Please let me know if you have...
6
by: Brad | last post by:
I have a win2003 server workstation with multiple webs, each web has it's own ip address. In VS2005, if I select to open an existing web site, select Local IIS, the dialog correctly displays a...
3
by: rdemyan via AccessMonster.com | last post by:
My application is split into a front end and back end. Each user has their own copy of the front end. There are a few forms I only want to be open for one user at a time. So I've implemented the...
1
by: Kiran | last post by:
See the docs: http://news.zdnet.com/2100-9593_22-6057835.html Download: http://www.ibm.com/software/data/db2/udb/viper/index_download.html Docs:...
1
lwwhite
by: lwwhite | last post by:
When a user clicks OK on form "SelectDefaults," I want to open form "Welcome" if the results of query "qry_todo_overdue" = 0 or form "OverdueToDo" if the results >= 1. First, I assume that I need to...
1
by: cbanks | last post by:
Hello Ladies/Gents, im in need of some serious help here.. I have a tool that allows users to view information on a form and make changes to recordsets. This tool has buttons that allow a user to...
4
by: nottarealaddress | last post by:
I'm trying to get my feet wet in VB2005 (our new standard at work after officially stopping new development in VB6 about a month ago). I'm working with a simple sql 2005 table of 50 entries, one...
0
by: trixxnixon | last post by:
i have a form that is being designed to pend requests in a requests database. the pend form is opened from an update form used by an employee to enter updates. when the pend form is updated, the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.