The code below in the Form Load Event of form SEARCHF if, works correctly, supposed to display records in two textboxes on the Form. . The first on the left, named txtMatchedVerses displays records from a table named tblSearchResults as shown in the top code block. That code block works great every time and the records are
displayed in txtMatchedVerses as shown in the image below.
The problem is with the second code block. This line is preventing further execution and I have no idea why:
This is the entire code block in the Form Load Event:
I don't know why the top code block runs and populates the txtMatchedVerses textbox like a charm, but has a problem with this line on the second code block:
The image below shows how both textboxes should look when the Form Load code for both textboxes works correctly.
My apologies for a lengthy post. Could not describe problem completely with less text and images.
I would greatly appreciate anyone's help. Been at trying to solve this mystery for the past 24 hours.
cr
displayed in txtMatchedVerses as shown in the image below.
The problem is with the second code block. This line is preventing further execution and I have no idea why:
Code:
Me.Controls("Textbox2").Value = IIf(Len(Me.Controls("Textbox2").Value) = 0, rs.Fields(1).Value, Me.Controls("Textbox2").Value & vbNewLine & rs.Fields(1).Value)
This is the entire code block in the Form Load Event:
Code:
Private Sub Form_Load()
Me.txtSearchCriteria = gSavedValue
Dim cnt As Long
If DCount("*", "tblSearchResults") > 0 Then
strSQL = "SELECT * FROM tblSearchResults;"
Set db = CurrentDb: Set rs = db.OpenRecordset(strSQL)
rs.MoveFirst
Do Until rs.EOF
Me.Controls("txtMatchedVerses").Value = IIf(Len(Me.Controls("txtMatchedVerses").Value) = 0, rs.Fields(0).Value, Me.Controls("txtMatchedVerses").Value & vbNewLine & vbNewLine & rs.Fields(0).Value)
rs.MoveNext
Loop
Set rs = Nothing: Set db = Nothing
Else
End If
cnt = DCount("*", "tblSearchResults")
Me.Totrows.Value = cnt
Dim cnt2 As Long
If DCount("*", "maktxtbx2tbl") > 0 Then
strSQL = "SELECT * FROM maktxtbx2tbl;"
Set db = CurrentDb: Set rs = db.OpenRecordset(strSQL)
rs.MoveFirst
Do Until rs.EOF
Me.Controls("Textbox2").Value = IIf(Len(Me.Controls("Textbox2").Value) = 0, rs.Fields(1).Value, Me.Controls("Textbox2").Value & vbNewLine & rs.Fields(1).Value) --->this is the line that gives 'Not responding' errror.
rs.MoveNext
Loop
Set rs = Nothing: Set db = Nothing
Else
End If
cnt = DCount("*", "maktxtbx2tbl")
Me.totrows2.Value = cnt2
End Sub
I don't know why the top code block runs and populates the txtMatchedVerses textbox like a charm, but has a problem with this line on the second code block:
Code:
Me.Controls("Textbox2").Value = IIf(Len(Me.Controls("Textbox2").Value) = 0, rs.Fields(1).Value, Me.Controls("Textbox2").Value & vbNewLine & rs.Fields(1).Value)
My apologies for a lengthy post. Could not describe problem completely with less text and images.
I would greatly appreciate anyone's help. Been at trying to solve this mystery for the past 24 hours.
cr