I have codes looking like followings. It is IF-THEN and While Loop.
I have about 100 lines of code being repeated twice. (exactly same code) How can I make this simpler?
I can use Function or Sub and pass variables but is there any other way to do this?
Thank you so much for your time. Always appreciate experts help here..
======= code sample follows...
Dim curdb As Object
Dim rst As DAO.Recordset
Set curdb = CurrentDb
Set rst = curdb.OpenRecordset("meme")
strwhere = "[meme] = " & Me!id
rst.MoveFirst
rst.FindFirst strwhere
If Not rst.NoMatch() Then
'** about 100 lines of code goes here
rst.FindNext strwhere
While Not rst.NoMatch()
'** about 100 lines of the same code goes here
rst.FindNext strwhere
Wend
Else
MsgBox "no match"
End If
rst.Close
Set rst = Nothing
I have about 100 lines of code being repeated twice. (exactly same code) How can I make this simpler?
I can use Function or Sub and pass variables but is there any other way to do this?
Thank you so much for your time. Always appreciate experts help here..
======= code sample follows...
Dim curdb As Object
Dim rst As DAO.Recordset
Set curdb = CurrentDb
Set rst = curdb.OpenRecordset("meme")
strwhere = "[meme] = " & Me!id
rst.MoveFirst
rst.FindFirst strwhere
If Not rst.NoMatch() Then
'** about 100 lines of code goes here
rst.FindNext strwhere
While Not rst.NoMatch()
'** about 100 lines of the same code goes here
rst.FindNext strwhere
Wend
Else
MsgBox "no match"
End If
rst.Close
Set rst = Nothing