Search results

  1. c_smithwick

    match whole word in vba

    The Instr Function looks for the occurrence of one string within another. It doesn't know whole words from characters, but you can use it to determine the position of the occurrance. Instr(1, "Word", "ZZWordYY") will return 3, indicating that the searched term "Word" occurs beginning at the...
  2. c_smithwick

    VBA-Syntax Error While Printing SQL Text of all Queries

    If you are calling a sub without the "Call" statement, you do not need to enclose the parameters in parenthesis. I suspect that may have been the source of your syntax error.
  3. c_smithwick

    Time on Job calculation

    The following function will return your string formatted as you want: Public Function TimeOnJob(dtStart As Date, dtEnd As Date) As String Dim intNmbrOfMonths As Integer intNmbrOfMonths = DateDiff("m", dtStart, dtEnd) TimeOnJob = intNmbrOfMonths \ 12 & " year" & IIf(intNmbrOfMonths \ 12 > 1 Or...
  4. c_smithwick

    Fuzzy Business Logic to prevent site duplicates

    Try the following on for size: Public Function checkForSimilar(strTableName As String, strFieldName As String, strTestString As String) As String ' Takes a table name, field name and input string as parameters. Checks for similar phrases in the table fields and ' presents the user with a...
  5. c_smithwick

    Grrrr!! Grumpy old fart here

    Things other than one-line IFs piss me off too, but I won't enumerate them all here. Bottom line my philosophy has always been if it's worth writing, it's worth writing right. If you are too lazy or rushed to split your declarations into separate lines or declare your variables as "strThis...
  6. c_smithwick

    Grrrr!! Grumpy old fart here

    I must confess, I'm a limited commenter myself, but I've found that if I stay VERY consistant with coding standards and write good, clean, consise and clear code that commenting requirements remain at a minmum anyway. For instance, if you write a function: Public Function reFormatString...
  7. c_smithwick

    Grrrr!! Grumpy old fart here

    It's a personal thing. I have written an add-in that I use to format all of my code, and one-line IF statements give it nightmares. Plus, I'm a stickler for consistancy, so I don't like a mix of multi-line IFs and one-line IFs. Kind of a self discipline thing - you either smoke or you don't...
  8. c_smithwick

    Grrrr!! Grumpy old fart here

    When I need reports in a strictly VB6 environment I either output the info to a Word document (and yes, I have to do ALL the formatting, etc in code) or to an HTML document (Nearly everyone has a browser installed and can view a web doc). I've used Crystal Reports, but was never really enthused...
  9. c_smithwick

    Grrrr!! Grumpy old fart here

    Grumpy old fart Self taught Access, Excel, Word, Powerpoint, Visio VBA and Visial Basic 6 guru. I have used all the programs since their invention - started out in DOS and Qbasic and yes, I even remember when computer programs had to be loaded on punch cards in FORTRAN Retired military (21...
  10. c_smithwick

    Email as Plain Text

    Assuming you are creating an Outlook Mail Item variable in VBA and using it to compose and send your message, then use the .Body property of your Outlook Mail Item object. This will format as plain text. You have to use the .HTMLBody property to send the message as HTML from VBA
  11. c_smithwick

    Error sending bulk emails using Outlook

    Have you tried passing in the recordset as a parameter and opening one outlook session to process the entire recordset? Try the below: Public Function SendBulkEmails(strSQL) As Boolean Dim db As DAO.Database Dim rs As DAO.Recordset Set db = CurrentDb Set rs = db.OpenRecordset(strSQL)...
  12. c_smithwick

    Calling public function based on data from parent form syntax

    Your function is set up to return a string value, but as formatted you are not doing that. Try the below changes: Public Function DateBucket(DDDate As Date) As String Select Case DDDate Case Is <= #3/20/2009# And DDDate >= #2/21/2009# DateBucket = "#3/20/2009#" Case Is <= #4/24/2009# And...
  13. c_smithwick

    Hide Access Application

    Check out this link: http://www.tek-tips.com/viewthread.cfm?qid=895857
  14. c_smithwick

    Update a table based on query results via VBA

    Try the following: Private Sub cmdExitandUpdate_Click() Dim rst As Recordset Dim nIndex As Integer Dim rstForm As Recordset Set rst = CurrentDb.OpenRecordset("select * from tblWorkRequests") Set rstForm = Forms("[Insert Your FormNameHere]").RecordsetClone rstForm.MoveFirst Do While Not...
  15. c_smithwick

    Calculating Holiday Entitlement

    This code: Me![txtHolsEntDays] = HolEntMon / WorkDay * Me![txtNumberOfWeeklyWorkDays] * MonthsPerYear is the same in each case - why duplicate it. Also, your constants are not likely to ever change (5 workdays and 12 months in a year) so hard coding them won't hurt and will save code...
  16. c_smithwick

    Update a table based on query results via VBA

    Your current query is only adding one record because it is only running for the currently selected record on the form. You need to establish reference to the forms recordset in vba and then execute a do loop to run the recordset and execute your query for each record. Why don't you just set...
  17. c_smithwick

    How to take a screenshot

    First use SendKeys {PRTSC} to get a copy of the screen into the clipboard, then read the post here to get the bitmap data from the clipboard into a file...
  18. c_smithwick

    Undo on error

    One simple solution would be to populate the combo box for "X" in the after_update event of the combo box for "Y". That way, until a user makes a "Y" choice, there is no "X" choice to be made, hence no error. Make the "X" combo box unbound and in the after_update event for the "X" combo box...
  19. c_smithwick

    Date ranges while using DCount

    Try this (I assume here that your date field is named fldDate=DCount("[Patient Type:]","metroQ","([Patient Type:]='Level 1 Care Coordination') AND ([fldDate] BETWEEN #" & InputBox("Enter Date 1") & "# AND #" & InputBox("Enter Date 2") & "#)")
  20. c_smithwick

    Give Access Query and Alias using VBA Code

    A solution and an issue. Your code as written jumps you out of the Sub on error. End Sub should ALWAYS be the final line of your Subroutine. The code below should do what your looking for: Private Sub Command85_Click() Dim User As String Dim strAlias As String User = Environ$("USERNAME")...
Back
Top Bottom