Results 1 to 2 of 2
  1. #1
    chromachem is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Feb 2016
    Posts
    49

    concatenate value in rst statement


    We are trying to concatenate in a rst statement. The commented line works just fine. Would like to make the next line work in the loop. I've tried many different variations. Just can't get it to work.


    Code:
    For intA = 7 To 25
    strA = "Me.Field" & intA
    Set dbs = CurrentDb
    'Set rst = dbs.OpenRecordset("SELECT Descrip FROM tbltests where tbltests.test ='" & Me.Field7 & "'; ")
    Set rst = dbs.OpenRecordset("SELECT Descrip FROM tbltests where tbltests.test ='" & strA & "'; ")
    
    If rst.RecordCount = 0 Then
    MsgBox "empty"
    End If
    
    
    strB = "txtDescrip" & intA
    strB = rst.DESCRIP
    
    
    
    
    Set rst = Nothing
    Set dbs = Nothing
    
    
    Next intA

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    This is not the way to do this. Either do it all in 1 query, or

    do it with 1 record, not loop 7 to 25



    Code:
    strA = "Me.Field" & intA
    Set dbs = CurrentDb
    'Set rst = dbs.OpenRecordset("SELECT Descrip FROM tbltests where tbltests.test ='" & Me.Field7 & "'; ")
    Set rst = dbs.OpenRecordset("SELECT Descrip FROM tbltests where tbltests.test ='" & strA & "'; ")
    
    If rst.RecordCount = 0 Then
    MsgBox "empty"
    else
    
    For intA = 7 To 25
    
    strB = "txtDescrip" & intA
    strB = rst.fields("DESCRIP" & intA ).value
    
    next

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 03-04-2016, 10:08 AM
  2. Concatenate with Tabs
    By Njliven in forum Queries
    Replies: 11
    Last Post: 01-25-2013, 08:58 AM
  3. Replies: 5
    Last Post: 03-13-2012, 01:13 PM
  4. Concatenate 2 columns in one
    By playas in forum Queries
    Replies: 2
    Last Post: 02-20-2012, 12:05 PM
  5. concatenate
    By stephenaa5 in forum Programming
    Replies: 2
    Last Post: 10-11-2010, 05:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums