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..![]()
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..![]()
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.
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
Basically I have
however if the variable already has the found text inside it I want it to remove that said text (the user clicks twice)Code:TempVars!tmpIntcheckGoogle = TempVars!tmpIntcheckGoogle + 1 TempVars!tmpIntSchoolList = [SchoolName] & vbCrLf + TempVars!tmpIntSchoolList Me.txtListSchools.Value = TempVars!tmpIntSchoolList Me.Refresh
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
counter isn't accurate...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
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.
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
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![]()
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