Results 1 to 7 of 7

Thread: [RESOLVED] Access: Multiple Select through 1 select statement

  1. #1

    Thread Starter
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Resolved [RESOLVED] Access: Multiple Select through 1 select statement

    View post #4






    I am not exactly sure how to explain this, but here is what I want to do:

    I have a table, with a layout as follows

    SplitNumber ID Course1 SD1 ED1 Course2 SD2 ED2...

    up until 15

    Now, I want to run a query to take that row, and place it into another table in the following layout

    Course SD ED
    Course2 SD ED
    Course3 SD ED

    up until 15

    I have tried thinking of ways to do it with a query, but have run short. And I cant seem to find any reference to this sort of problem in any of the books I have.

    If anyone could even point me in the right direction with some keywords to search or anything I would greatly appreciate it.
    Last edited by kfcSmitty; Aug 5th, 2005 at 09:42 AM.

  2. #2
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: Access: Query row

    Kfc

    So basically you want to take the columns and place them into one column.. ie concatenate the columns? Or have mis-read
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

  3. #3

    Thread Starter
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: Access: Query row

    I want to take the rows, and split them into columns

    Here is the code I am trying, keeps giving me an error though

    VB Code:
    1. Dim rsSplitting As ADODB.Recordset
    2. Set rsSplitting = New ADODB.Recordset
    3. Dim strTest As String
    4. Dim strTest2 As String
    5. Dim strTest3 As String
    6. strTest = "Select Course" & lstSplit.Value & " from Splits where SplitsNumber > 0"
    7. strTest2 = "Select SD" & lstSplit.Value & " from Splits where SplitsNumber > 0"
    8. sttrTest3 = "Select SD" & lstSplit.Value & " from Splits where SplitsNumber > 0"
    9. MsgBox "StrTest: " & strTest
    10. rsSplitting.Open strTest, con, adOpenKeyset, adLockPessimistic, adCmdText
    11.     txtCourse.SetFocus
    12.     txtCourse.Text = rsSplitting.Fields("Course" & test)
    13. rsSplitting.Close
    14. rsSplitting.Open strTest2, con, adOpenKeyset, adLockPessimistic, adCmdText
    15.     txtsd.SetFocus
    16.     txtsd.Text = rsSplitting.Fields("SD" & test)
    17. rsSplitting.Close
    18. rsSplitting.Open strTest3, con, adOpenKeyset, adLockPessimistic, adCmdText
    19.     txted.SetFocus
    20.     txted.Text = rsSplitting.Fields("ED" & test)
    21. rsSplitting.Close

    If you could tell me how to use multiple selects in 1 select statement I would appreciate it , and the error I get is on

    VB Code:
    1. rsSplitting.Open strTest, con, adOpenKeyset, adLockPessimistic, adCmdText

    and the error is

    Quote Originally Posted by Runtime Error '3001'
    Arguements are of the wrong type, are out of acceptable range, or are in conflict with one another
    And the messagebox I have there is displaying

    "Select Course1 from Splits where SplitsNumber > 0"

  4. #4

    Thread Starter
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: Access: Query row

    Solved it
    VB Code:
    1. Private Sub Form_Current()
    2. Dim rsSplitting As ADODB.Recordset
    3. Set rsSplitting = New ADODB.Recordset
    4. Dim strTest As String
    5. Dim strTest2 As String
    6. Dim strTest3 As String
    7. ID.SetFocus
    8. strTest = "Select Course" & lstSplit.Value & " from Splits where ID = " & "'" & ID.Text & "'"
    9. strTest2 = "Select SD" & lstSplit.Value & " from Splits where ID = " & "'" & ID.Text & "'"
    10. strTest3 = "Select ED" & lstSplit.Value & " from Splits where ID = " & "'" & ID.Text & "'"
    11. rsSplitting.Open strTest, con, adOpenKeyset, adLockPessimistic, adCmdText
    12.     txtCourse.SetFocus
    13.     txtCourse.Text = rsSplitting.Fields("Course" & test)
    14. rsSplitting.Close
    15. rsSplitting.Open strTest2, con, adOpenKeyset, adLockPessimistic, adCmdText
    16.     txtStartDate.SetFocus
    17.     txtStartDate.Text = rsSplitting.Fields("SD" & test)
    18. rsSplitting.Close
    19. rsSplitting.Open strTest3, con, adOpenKeyset, adLockPessimistic, adCmdText
    20. MsgBox strTest3
    21.     txtEndDate.SetFocus
    22.     txtEndDate.Text = rsSplitting.Fields("ED" & test)
    23. rsSplitting.Close
    24. End Sub

    Works


    New question: Could someone tell me, is it possible to select multiple columns through 1 select statement?

  5. #5
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: Access: Multiple Select through 1 select statement

    Selecting multiple columns..

    "SELECT Course" & lstSplit.Value & ", SD" & lstSplit.Value & ", ED" & lstSplit.Value & " FROM Splits WHERE ID = " & "'" & ID.Text & "'"
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

  6. #6

    Thread Starter
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: Access: Multiple Select through 1 select statement

    Much obliged, although I can't rep you yet

  7. #7
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: [RESOLVED] Access: Multiple Select through 1 select statement

    Not a problem...
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width