VBA SQL Strings - Tutorial for Beginner

Поділитися
Вставка
  • Опубліковано 20 жов 2024

КОМЕНТАРІ • 47

  • @kamal265
    @kamal265 2 роки тому +1

    God bless you dear sir, lots of respect from India 🙏🇮🇳

  • @JANtheDane
    @JANtheDane 6 років тому +6

    Thank you so much. I have seen a lot of really excellent MS Access programming videos. However, this particular video is the most useful ever! I have encountered more confusion from strings and quotation marks than anything else in this programming language. Thank you for making this clear.

  • @rogermckee4249
    @rogermckee4249 4 роки тому +2

    After days of watching other tutorials this gave me my eureka moment and solved my multiple apostrophe problems.
    Danke Sehr ,ein tolles Tutorial

  • @radiusbecka1799
    @radiusbecka1799 3 роки тому +2

    Thank you this helped so much. All I wanted was the Syntax to pass a vba variable to a sql command and I finally found it.

  • @ashishtrivedi8253
    @ashishtrivedi8253 2 роки тому +1

    Great help in understanding how to put different values in SQL query in VBA which i was looking for from long time and this is completely cleared my confusion. Thx a ton.

  • @LordBransty
    @LordBransty 5 років тому +3

    Superb video. Thank you very much. Wish there were more teachers like you. !!!

  • @davegoodo3603
    @davegoodo3603 7 років тому +2

    I've been looking all over for a video like this. Excellent video.
    Cleared up a lot of confusion on this topic, thanks.

  • @Souhila-yi8qk
    @Souhila-yi8qk 5 місяців тому +1

    Thank you for the interesting Video. It helped me how to put a String variable inside a query.

  • @royzra
    @royzra Рік тому +1

    Excellent narration on basics . Thank you very much....

  • @雅楽川圭典
    @雅楽川圭典 5 років тому +2

    Thank you very much sir!
    This is extremely helpful for my interview next week!

  • @petegarner1059
    @petegarner1059 3 роки тому +2

    Really good explanations and code development. Thank you.

  • @danter399
    @danter399 4 роки тому +2

    Love this video, thanks you very much. Now I understand why my slq structure in vba didn't run haha. Kind regards

  • @santosozhang1985
    @santosozhang1985 2 роки тому +1

    Excellent Teaching, very helpful. Thank You.

  • @vikrantchouhan9908
    @vikrantchouhan9908 5 років тому +2

    Awesome! It resolved the issues that I was struggling with.

  • @sarojray2779
    @sarojray2779 2 роки тому +1

    Love❤️ you my friend, it sorted my critical issues. Thank you so much genius...

  • @arabicgrammereasytolearnqu6333
    @arabicgrammereasytolearnqu6333 2 роки тому +1

    I like and say that u r the best programer
    Thanks

  • @caleblear3671
    @caleblear3671 5 років тому +2

    You do a great job in this tutorial. Thanks so much!

  • @charlesbuckle5345
    @charlesbuckle5345 2 роки тому +1

    Excellent video, thank you.

  • @goodyearspokane
    @goodyearspokane 4 роки тому +2

    Thanks for the video. What is your solution if you have a very long query? Currently I just have my long query as an Access query and use DoCmd.OpenQuery but I would much rather have less Access queries and have the SQL in VBA

    • @codekabinettcomen
      @codekabinettcomen  4 роки тому

      Although I'm not entirely sure about the core issue, I love your question.
      There's no quick and simple answer. I'm thinking about doing a video on that topic...

  • @nithiyashreeg7507
    @nithiyashreeg7507 4 роки тому +2

    Excellent ..!Its extremely helpful

  • @NoL1mit985
    @NoL1mit985 6 років тому +1

    Du hast mir den Arsch gerettet mit dem Video, saubere Arbeit. Ich bin fast durchgedreht und alt geworden, aber jetzt geht mein Programm und das alles wegen einem "'"

  • @kebincui
    @kebincui 4 місяці тому +1

    excellent video. Thanks

  • @midhunraj6261
    @midhunraj6261 6 років тому +4

    Great tutorial and good explanation...

  • @adnanelaiwah3599
    @adnanelaiwah3599 5 років тому +2

    Very useful , simple
    Thank you

  • @raselbiswas4083
    @raselbiswas4083 6 років тому +2

    Hi There,
    I like your lecture a lot. But I have a question to you regarding ShowDataSheet function. Do you write this or it is a defined function in VBA? I use the the same data table and same query as well. But it says ShowDataSheet function is not defined. Can you please clarify us in this regard. It would be appreciated. Thanks in Advance.

    • @raselbiswas4083
      @raselbiswas4083 6 років тому

      Dear Sir, Thanks a lot. I get of it!

    • @codekabinettcomen
      @codekabinettcomen  6 років тому

      Thank you very much for your feedback! The ShowDataSheet function is a custom function. Watch my latest video, there it is explained in detail. -> ua-cam.com/video/S_z-Rg4v3wg/v-deo.html

    • @raselbiswas4083
      @raselbiswas4083 6 років тому

      Dear Sir, I have a question regarding Runtime Error 3141:
      Sometimes my program does not work, it shows Runtime Error 3141. As for example,
      Dim sqlString As String
      sqlString = "SELECT target_table420.TraderID, target_table420.Side, Sum([target_table420].[EQuantity]*[target_table420].[EPrice]) AS AskAmount," & _
      "FROM target_table420" & _
      "GROUP BY target_table420.TraderID, target_table420.Side" & _
      "HAVING (target_table420.Side=""Ask"");"
      DoCmd.RunSQL (sqlString)

    • @codekabinettcomen
      @codekabinettcomen  6 років тому

      Two issues are apparent with your code. 1.) there is a surplus comma before FROM, 2.) RunSQL is meant for DML (Action Queries), it will not work with Select-Queries.

  • @willhan6808
    @willhan6808 6 років тому +2

    Can someone simply let me know which library is this ShowDataSheet Method located? I cannot call this function even with DAO, Access library activated.

    • @codekabinettcomen
      @codekabinettcomen  6 років тому

      The ShowDataSheet method is a custom method I wrote. Look at the info text of this video. There's a download link to the sample file containing that method.

    • @willhan6808
      @willhan6808 6 років тому

      Thanks that helps!

  • @micron001
    @micron001 3 роки тому +2

    Well done vid. I'd give it 99.5 out of 100. Would have been perfect if the problem of words with apostrophes was covered (e.g. O'Brien).

    • @oliveroshea5765
      @oliveroshea5765 2 роки тому +1

      Just add an extra apostrophe/quote , so that it looks like O’’Brien. (That is 2 single quotes)
      SQL will then adjust it. This is certainly the case for SQL Server. Access might not even need it

  • @SavedbyGraceCT
    @SavedbyGraceCT 9 місяців тому +1

    Thank you so much!

  • @sharif7351
    @sharif7351 2 роки тому +1

    Wonderful!

  • @patrickwheeler7107
    @patrickwheeler7107 3 роки тому +1

    Great tutorial

  • @XxLenasXx
    @XxLenasXx 4 роки тому +1

    Awesome video....again.

  • @ahmadharb4503
    @ahmadharb4503 6 років тому +1

    I was trying to make a vba in excel using sql commands to export data to access, your method worked, but for some cases where i had field name ending with a question mark for example, "explicit?" while debugging excel could read the variable that contains "explicit?" but did not print it in access. ... so in other words it worked for all normal text but not for text ending with a question mark, although access accepts a question mark at the end of a field name so what can I do here? thank you
    For j = 2 To RowTable
    MyString = Worksheets("Sheet1").Cells(j, 1)
    MyFeild = Worksheets("Sheet1").Cells(j, 2)
    MyFeildType = Worksheets("Sheet1").Cells(j, 3)
    If MyFeildType = "COUNTER" Or MyFeildType = "Text(128) " Or MyFeildType = "INTEGER" Then
    Else: Worksheets("Sheet1").Cells(j, 3) = "Text(128)"
    End If
    On Error Resume Next
    MyDatabase.Execute "CREATE Table " & MyString & " " _
    & "(" & MyFeild & " " & MyFeildType & " CONSTRAINT MyFieldConstraint " _
    & "PRIMARY KEY);"

    MyDatabase.Execute "ALTER TABLE " & MyString & " " _
    & "ADD COLUMN " & MyFeild & " " & MyFeildType & ";"
    Next j

    • @codekabinettcomen
      @codekabinettcomen  6 років тому +1

      Ahmad, thank you for bringing this up. I should have mentioned and shown this in the video.
      If your column or table names include special characters or spaces, you should enclose the name in square brackets. E.g.: [explicit?]
      Here is your last statement adapted for this scenario:
      MyDatabase.Execute "ALTER TABLE [" & MyString & "] " _
      & "ADD COLUMN [" & MyFeild & "] " & MyFeildType & ";"
      Nevertheless, I recommend NOT to use special characters in table or column names.

    • @ahmadharb4503
      @ahmadharb4503 6 років тому

      It worked! thank you a lot for this video and for your comment :)

  • @Joker1SH
    @Joker1SH 4 роки тому +1

    Klasse - TOP

  • @arabicgrammereasytolearnqu6333
    @arabicgrammereasytolearnqu6333 2 роки тому +1

    U r genius

  • @automationguide3498
    @automationguide3498 7 років тому +1

    Thank You !!