Hi [FirstName], Simply Access Tips Issue 13 2007 May 4 th, 2007 Welcome to the thirteenth edition of Simply Access Tips for 2007. Housekeeping as usual is at the end of the Newsletter so, if you need to know how to unsubscribe, white-list, etc., then scroll to the bottom. Weekly Update Hello [FirstName], Back to work full time this week. So far so good. I have even got this Newsletter out on time, well almost. It has finally rained here, the most rain I ve seen for a long time 52 mm in a bit over a week. It is amazing how quickly grass comes back. We have nature strips again and the golf course is green again. Hopefully this is the start of good things. I do dabble in golf. I can t say I play as yet, I am a rank beginner. Good for a bit of gentle exercise, but it can be an extremely frustrating game. One advantage of the drought was there was no water ways to worry about when we were learning. My ball landed in a puddle (in what I think is normally a water way) for the first time tonight; but it was only 1 cm in depth, so no great trouble hitting it out. I enjoy the cooler weather; it seems to give me a bit more energy. I have taken to moving the house around over the last couple of weeks. I want to set up an art room downstairs, where I can do a bit of drawing, painting and paper mache. There is a bit more work to do yet, but it is coming along nicely. Julie Questions Unfortunately, I am unable to answer individual questions, personally, via email. Purely due to the fact that all I would do is answer questions. You do, though, have three other options for me to answer your questions:
1) I can include them in an edition of Simply Access Tips (if you do not mind your question being shared). There may be a wait before they are included, depending on how many I have. 2) You can go to All Experts and post your question there; I answer one question per day from All Experts (this helps to keep control of the questions): http://www.allexperts.com/browse.cgi?catlvl=3&catid=1440 If I am not available, there are many other experts. 3) Or, you can subscribe to my Question Subscription Service, $23.95 AUD per month, for unlimited questions: http://www.simply-access.com/microsoftaccessquestions.html Learn VBA You may have noticed I have used VBA code in some of my answers. If you would like to learn this valuable skill to enable you to expand the flexibility of your Microsoft Access database, then click below to get your first lesson free, or cut and paste into your URL Address bar. You will need to scroll to the bottom of the page and enter your information into the form. http://www.simply-access.com/learnvba.html Tips NOTE: If you are copying code from the tips and find it is not copying correctly i.e. the html is also being copied, then copy them into NotePad first (not Microsoft Word, as Word keeps the formatting) then copy from NotePad into Microsoft Access. Tip 1: Random Numbers (a better solution) This tip is thanks to Walter. If any of you have better and/or more efficient ways of doing things let me know. Or if I am just plain wrong please also let me know. I am not infallible by any means. Then I can learn as well, and share it with everyone else. So thanks Walter. This is what he said: In issue 11-2007 you gave coding to choose random records from a table (recordset). Your coding picks a random record number then returns the key of the table for that record. I have a suggested change to make the function much more efficient.
In your code you walk through the table, from the first record, until you reach the record number calculated by random. If the table is large, this could take some time. Instead, set the recordset's AbsolutePosition property to the random record number (don't add 1 to it because this is a zero-based property). Then, return the key of the current record. Therefore the code would look like this Note: the code is mine so if there are mistakes let me know: Public Function frandom() On Error GoTo ErrorHandling 'Declare all the variables Dim db As Object Dim rst As Object Dim inumberrecords As Integer Dim irecordid As Integer Dim i As Integer 'Reference the database and recordset you wish to use, change 'tblcustomer' to 'the name of the table the cheques are in. Set db = CurrentDb Set rst = db.openrecordset("tblcustomer", dbopensnapshot) 'Moves to the first, then to the last record in order to be able to count the number 'of records rst.movefirst rst.movelast inumberrecords = rst.recordcount 'Randomly selects a number from this record set ' AbsolutePosition only works with dynasets or snapshots. rst.absoluteposition = Int((iNumberRecords) * Rnd) 'Assigns the value of the Primary Key for the recordset, in this case CustomerID, change to 'the primary key for your record set. Likely to be the cheque number field. frandom = rst!customerid 'The above code displays X 1 random number, this will be called X 5 times from a form. Exit Function ErrorHandling:
MsgBox Err.Number & ": " & Err.Description End Function Tip 2: Excluding weekdays Question Is there a way to have a query pull only dates on a rolling 20 day time frame, but that excludes weekends? In other words, it displays the past 20 weekdays, excluding weekends. Answer To do this; try the following: In a query in design view, in the 'field' row of an empty column, type the following: WeekDays: Weekday([DateField]) Change DateField, to the name of your date field. In the 'criteria' row for this same column, type the following: <>1 And <>7 (1 and 7 are the default weekend days in Microsoft Access) Next to get the previous 20 days, add your date field to the query and in the 'criteria' row type the following: Between Date() And Date()-20 Tip 3: Microsoft Access Lock file Question How do I open file type access lockfile 9.Whenever I try to open it Iget no response. Answer You should be able to open the *.ldb file with notepad to view the users who were [are] in the database. It will list their workgroup name and computer name.
You should be prompted with what program you wish to open it with, when you double click on it. Housekeeping Once again, just a quick reminder: Please ensure the following email address is whitelisted with your ISP: jmisson@iprimus.com.au This will ensure the weekly arrival of this Newsletter. Unsubscribe To unsubscribe to this Newsletter, just hit the REPLY button and type UNSUBSCRIBE in the subject section of the Email. I will remove you from my emailing list. You will not receive any more Newsletters unless you re-apply via the website.