Results 1 to 10 of 10
  1. #1
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496

    Search and find then remove in variable

    I would like to search a variable for a string and if it matches remove just that part of the string



    something like

    search strings in variable a

    find ("house" & vbCrLf)

    if match replace "house & vbCrLf" in variable with ""

    no idea how..

  2. #2
    trevor40's Avatar
    trevor40 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Feb 2014
    Location
    Australia
    Posts
    407
    Try
    Replace Function or Instr with code



    1000 ways to skin a cat, allways looking for another one...
    Use MDB format for sample post. If your issue is fixed, mark the thread solved.
    Click on the star below if this has helped.

  3. #3
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    I had tried that

    ignore below
    Code:
    Dim strSchools As Variant
    
    
    strSchools = TempVars!tmpIntSchoolList.Value
    strSchools = Replace(strSchools, [SchoolName], "")
    
    
    TempVars!tmpIntSchoolList = strSchools
    Me.txtListSchools.Value = TempVars!tmpIntSchoolList
    
    
    TempVars!tmpIntcheckGoogle = TempVars!tmpIntcheckGoogle - 1
    
    
    TempVars!tmpIntcheckGoogle = TempVars!tmpIntcheckGoogle + 1
    TempVars!tmpIntSchoolList = [SchoolName] & vbCrLf
    Me.txtListSchools.Value = TempVars!tmpIntSchoolList
    Me.Refresh

  4. #4
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Basically I have

    Code:
    TempVars!tmpIntcheckGoogle = TempVars!tmpIntcheckGoogle + 1
    TempVars!tmpIntSchoolList = [SchoolName] & vbCrLf + TempVars!tmpIntSchoolList
    Me.txtListSchools.Value = TempVars!tmpIntSchoolList
    
    
    
    
    
    Me.Refresh
    however if the variable already has the found text inside it I want it to remove that said text (the user clicks twice)

  5. #5
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    This works however I need the counter to go down on the condition of the replace


    Code:
    TempVars!tmpIntSchoolList = Replace(TempVars!tmpIntSchoolList, [SchoolName], "")
    
    
    TempVars!tmpIntcheckGoogle = TempVars!tmpIntcheckGoogle + 1
    TempVars!tmpIntSchoolList = [SchoolName] & vbCrLf + TempVars!tmpIntSchoolList
    Me.txtListSchools.Value = TempVars!tmpIntSchoolList
    
    
    
    
    Me.Refresh

  6. #6
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Code:
    Dim testpos As Integer
    testpos = InStr(1, TempVars!tmpIntSchoolList, [SchoolName] & vbCrLf, vbUseCompareOption)
    
    
    If testpos = 1 Then
    TempVars!tmpIntSchoolList = Replace(TempVars!tmpIntSchoolList, [SchoolName] & vbCrLf, "")
    TempVars!tmpIntCheckGoogle = TempVars!tmpIntCheckGoogle - 1
    Me.txtListSchools.Value = TempVars!tmpIntSchoolList
    ElseIf testpos = 0 Then
    
    
    End If
    
    
    
    
    
    
    
    
    
    
    
    
    TempVars!tmpIntCheckGoogle = TempVars!tmpIntCheckGoogle + 1
    TempVars!tmpIntSchoolList = [SchoolName] & vbCrLf + TempVars!tmpIntSchoolList
    Me.txtListSchools.Value = TempVars!tmpIntSchoolList
    
    
    
    
    Me.Refresh
    
    
    End Sub
    counter isn't accurate...

  7. #7
    trevor40's Avatar
    trevor40 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Feb 2014
    Location
    Australia
    Posts
    407
    Never needed to work with tempvas, your on your own...

    1000 ways to skin a cat, allways looking for another one...
    Use MDB format for sample post. If your issue is fixed, mark the thread solved.
    Click on the star below if this has helped.

  8. #8
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    ok works now

    thanks trevor40

    Code:
    Private Sub Command7_Click()
    
    
    Dim testpos As Integer
    testpos = InStr(1, TempVars!tmpIntSchoolList, [SchoolName], vbUseCompareOption)
    MsgBox testpos
    If testpos <> 0 Then
    TempVars!tmpIntSchoolList = Replace(TempVars!tmpIntSchoolList, [SchoolName] & vbCrLf, "")
    TempVars!tmpIntSchoolList = Replace(TempVars!tmpIntSchoolList, [SchoolName], "")
    Me.txtListSchools.Value = TempVars!tmpIntSchoolList
    TempVars!tmpIntCheckGoogle = TempVars!tmpIntCheckGoogle - 1
    Me.Refresh
    ElseIf testpos = 0 Then
    End If
    
    
    
    
    
    
    
    
    
    
    
    
    TempVars!tmpIntCheckGoogle = TempVars!tmpIntCheckGoogle + 1
    TempVars!tmpIntSchoolList = [SchoolName] & vbCrLf + TempVars!tmpIntSchoolList
    Me.txtListSchools.Value = TempVars!tmpIntSchoolList
    
    
    
    
    Me.Refresh
    
    
    End Sub

  9. #9
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by trevor40 View Post
    Never needed to work with tempvas, your on your own...

    thats ok - have it sorted now anyway

    All it does is populate a message box with some choices of schools, then later another button will search the map for that group of schools selected but the message box just shows the user what choices they have made

  10. #10
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    If anyone wants a cleaner version

    Code:
    Dim testpos As Integer
    testpos = InStr(1, TempVars!tmpIntSchoolList, [SchoolName], vbUseCompareOption)
    
    
    If testpos <> 0 Then
    TempVars!tmpIntSchoolList = Replace(TempVars!tmpIntSchoolList, [SchoolName] & vbCrLf, "")
    TempVars!tmpIntSchoolList = Replace(TempVars!tmpIntSchoolList, [SchoolName], "")
    Me.txtListSchools.Value = TempVars!tmpIntSchoolList
    TempVars!tmpIntCheckGoogle = TempVars!tmpIntCheckGoogle - 1
    ElseIf testpos = 0 Then
    TempVars!tmpIntCheckGoogle = TempVars!tmpIntCheckGoogle + 1
    TempVars!tmpIntSchoolList = [SchoolName] & vbCrLf + TempVars!tmpIntSchoolList
    Me.txtListSchools.Value = TempVars!tmpIntSchoolList
    End If
    
    Me.Refresh

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

Similar Threads

  1. Replies: 11
    Last Post: 11-19-2013, 09:03 AM
  2. Using search field to find matching data
    By rthakral in forum Access
    Replies: 2
    Last Post: 08-19-2013, 12:18 PM
  3. Search and Find Records Textbox
    By accessissue in forum Programming
    Replies: 2
    Last Post: 04-13-2012, 06:16 PM
  4. Replies: 1
    Last Post: 01-12-2011, 10:11 AM
  5. program find button to search whole table
    By sammer021486 in forum Programming
    Replies: 2
    Last Post: 10-01-2009, 06:36 AM

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