User Profile

Collapse

Profile Sidebar

Collapse
Uncle Dickie
Uncle Dickie
Last Activity: Mar 17 '22, 04:23 PM
Joined: Nov 4 '08
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Use a combination of the UPPER and LOWER functions e.g.

    Code:
    DECLARE	@text as varchar(5)
    SET	@text = 'Hello'
    
    SELECT	lower(left(@text,LEN(@text)-1)) + UPPER(RIGHT(@text,1))
    See more | Go to post

    Leave a comment:


  • Uncle Dickie
    replied to VBA for importing a formatted txt file
    Thanks again. I have something working (with absolutely no error trapping as you mentioned) as follows:

    Code:
        'Need to ensure that Microsoft Scripting Runtime is enabled from the Tools, References menu
        
        DoCmd.SetWarnings False
        
        
        Dim myDirectory As String
        Dim myFile As File
    '    Dim myFileCount As Integer
        
        Dim myFileName As String
    ...
    See more | Go to post

    Leave a comment:


  • Uncle Dickie
    replied to VBA for importing a formatted txt file
    Thanks ZMBD!

    I am getting somewhere now, although not with your suggestion...

    I have found another reference to using Microsoft Scripting Runtime and have been working through something with that (as below). Does that seem like a sensible route to follow or should I go back to your suggestion of 'Open x For Input'?

    I must confess I got confused reading your link so haven't tried it, but then I got confused reading...
    See more | Go to post
    Last edited by Uncle Dickie; Mar 13 '13, 04:17 PM. Reason: Added version of Access

    Leave a comment:


  • Uncle Dickie
    replied to VBA for importing a formatted txt file
    Thanks for the pointer.
    I have not tried anything other than the TransferText function of my original post but I will now go through the File I/O parsing and see where I get. Once I have made some progress (or not!) I will post again.
    See more | Go to post

    Leave a comment:


  • Uncle Dickie
    started a topic VBA for importing a formatted txt file

    VBA for importing a formatted txt file

    Hi All,

    I am trying to bring a text file in to an Access table using VBA.

    My problem is that the generated text file has a mixture of delimited and non-delimited data and I can't seem to work out how to use the Import Wizard to save a particular format and then use it with
    Code:
    DoCmd.TransferText acImportDelim, "MySavedFormat", "TableName", "C:\File.txt", True
    Maybe that...
    See more | Go to post

  • Someone else will no doubt come along and say the same, but please use the [CODE/] tags when putting up your code.

    The following works out the number of working days between 2 dates (assuming Sat and Sun are non-working)

    Code:
    DECLARE @start datetime
    SET @start = '2013-12-01'
    
    DECLARE @end datetime
    SET @end = '2014-01-01'
    
    DECLARE @fix int
    SET @fix = CASE
                 WHEN datepart(w,@start)
    ...
    See more | Go to post
    Last edited by Uncle Dickie; Mar 1 '13, 07:10 AM. Reason: mention code tags

    Leave a comment:


  • Start it with:

    Code:
    USE <database>
    GO
    CREATE PROCEDURE <procedure_name> AS
    
    -- your query here
    If you need to edit it in future:
    Code:
    ALTER PROCEDURE <procedure_name> AS
    See more | Go to post

    Leave a comment:


  • You should be able to use an UPDATE query, something like

    Code:
    UPDATE table_name
    SET column_name = new_value
    WHERE ID = ID_value
    See more | Go to post

    Leave a comment:


  • Uncle Dickie
    replied to More than Running Totals...
    Well that was a good way to get me to fix the problem!

    I didn't want to look too stupid when I posted my code by missing something obvious so I spent a few minutes looking at it and it now runs in less than 1 second!

    My problem was using a view that I had created. This view gets used multiple times and was what the running sums were worked out on. In an earlier attempt at getting the info something I was trying to do...
    See more | Go to post

    Leave a comment:


  • Uncle Dickie
    replied to More than Running Totals...
    Thanks Rabbit!

    I have something working almost as I want it by comparing running sums for in and out.
    It's dog slow - takes about 15 minutes to run - but it is better than the 3 hours that it would take to get the information manually so for the time being I'm calling it good enough!

    I have not used cursors before so when I am feeling a bit more adventurous I may revisit this report and see if I can make improvements...
    See more | Go to post

    Leave a comment:


  • Uncle Dickie
    started a topic More than Running Totals...

    More than Running Totals...

    I've hit a wall and would appreciate any pointers in moving forward on some code...

    I have some data in the following format:

    ID, QtyIN, QtyOUT
    1, 30, 0
    13, 0, 40
    16, 50, 0
    32, 0, 40

    Basically showing stock movements for a part, purchases and sales.

    What I am trying to get is for every QtyOUT the ID for each QtyIN that...
    See more | Go to post

  • Uncle Dickie
    replied to Pause while QueryTables import
    Thanks for the reply.

    I have tried your two suggestions as well as a few other variations on the theme and I still have no joy.

    I thought it may have been to do with the ScreenUpdating that was disabled but I have tried flicking that on and off during the 'time wasting' loops.

    As a final resort I have split the code into 2, the import triggered by one button click and the formatting done once you can see it...
    See more | Go to post

    Leave a comment:


  • Uncle Dickie
    started a topic Pause while QueryTables import

    Pause while QueryTables import

    Hi All,

    I have some VB in Excel 2007 which has stopped working since it moved from Excel 2003.

    I think the problem is that the QueryTable has not been imported by the time the rest of the code has run but I don't know how to pause!

    The variable myProd comes back with 0 and then the For loop does very little!

    If I put a break point in the code and then step through a couple of lines it all...
    See more | Go to post

  • Uncle Dickie
    started a topic Using Excel to update a SQL table

    Using Excel to update a SQL table

    Hi All,

    I have an situation where I am exporting from our SQL database a list of open purchase orders. In Excel, a user will be able to add a comment against any of these in a new column and then, when they run a Macro, it has to store the PO Number, Comment and today's date in to a separate table I have created in the database.

    Is this possible and if so does anyone have any pointers for doing the update?
    ...
    See more | Go to post

  • Uncle Dickie
    replied to Sorting
    Not sure if you will have found a solution to this but the following concept should work:
    • Find the minimum of the columns.
    • If it is from the Assembly column, multiply it by -1.
    • Create a new column which has either a 1 or 2 in it, 1 if it came from Average and 2 if it came from Assembly
    • Sort the data by the new column and then by the modified minimum


    An example of this which works in SQL

    Code:
    SELECT   partID
    ...
    See more | Go to post

    Leave a comment:


  • Uncle Dickie
    replied to Left Join Query Problem
    Use a CASE statement in the SELECT part rather than a WHERE condition.

    Something like:
    Code:
    CASE subscription_id
      WHEN 456 THEN imageURL
      ELSE null
    END
    Hope this helps!
    See more | Go to post

    Leave a comment:


  • You could try something like the following(I would guess that you can set your drop down to ignore the mySort field so it doesn't show on your form) :

    Code:
    SELECT MessageTable.Title,
           2 AS mySort
    FROM dbo.MessageTable
    INNER JOIN dbo.PreacherTable
    ON
    dbo.PreacherTable.PreacherID=dbo.MessageTable.PreacherID
    WHERE dbo.PreacherTable.PreacherID=1
    UNION
    SELECT Upper('Please select A Title'
    ...
    See more | Go to post

    Leave a comment:


  • The function below may get what you are after, it works on a very limited test I have done. There is no error trapping in the function so if there are not enough carriage returns (i.e. at least 2) it may have a fit!:

    Code:
    FUNCTION MySplit(@Line int, @str nvarchar(255))
    RETURNS nvarchar(255)
    
    AS
    BEGIN
    
    DECLARE	@Output nvarchar(255)
    
    SET @Output = CASE	@Line
    				WHEN 1 THEN	substring(@Str,1,CHARINDEX(char(13),
    ...
    See more | Go to post

    Leave a comment:


  • which solution?
    Leon's or mine?
    See more | Go to post

    Leave a comment:


  • Will this help you:

    Code:
    SELECT		substring(Course,0,6)
    			,count(substring(Course,0,6))
    FROM		dbo.R_test
    GROUP BY	substring(Course,0,6)
    ?
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...