Checkbox to change forms record source

  • Thread starter Thread starter deb
  • Start date Start date
D

deb

Access2003

I have a form called fMOrderSearch.
On the form I created an Option group called optRecSource using 2 checkboxes.
Check56 -Option Value 1 and Check58 -Option Value 2

I would like to change the forms recordsource according to which check box
is selected.

If Option Value 1
SELECT ApprovalStatus, CCode, CCodeDetail, CurrentQueue, Desc, EDate, Yr1,
Yr2, Yr3, Yr4, CustName FROM tNonconformance ORDER BY tNonconformance.EDate
DESC;--

If Option Value 2
SELECT ApprovalStatus, CCode, CCodeDetail, CurrentQueue, Desc, EDate, Yr1,
Yr2, Yr3, Yr4, CustName FROM tMYNonconformance ORDER BY
tMYNonconformance.EDate DESC;--

Thanks in advance

deb
 
Hi Deb,
In the AfterUpdate event of the option group insert code like this

Dim strSelect As String
Dim strFrom As String
Dim strOrderBy As String

strSelect = "SELECT ApprovalStatus, CCode, CCodeDetail, CurrentQueue,
_
Desc, EDate, Yr1, Yr2, Yr3, Yr4, CustName "

Select Case optRecSource
Case 2 ' use MY
strFrom = " FROM tMYNonconformance "
strOrderBy= " ORDER BY tMYNonconformance.EDate DESC;"
Case Else
strFrom = " FROM tNonconformance "
strOrderBy = " ORDER BY tNonconformance.EDate DESC;"
End Select

Me.RecordSource = strSelect & strFrom & StrOrderBy


--
Len
______________________________________________________
remove nothing for valid email address.
| Access2003
|
| I have a form called fMOrderSearch.
| On the form I created an Option group called optRecSource using 2
checkboxes.
| Check56 -Option Value 1 and Check58 -Option Value 2
|
| I would like to change the forms recordsource according to which check
box
| is selected.
|
| If Option Value 1
| SELECT ApprovalStatus, CCode, CCodeDetail, CurrentQueue, Desc, EDate,
Yr1,
| Yr2, Yr3, Yr4, CustName FROM tNonconformance ORDER BY
tNonconformance.EDate
| DESC;--
|
| If Option Value 2
| SELECT ApprovalStatus, CCode, CCodeDetail, CurrentQueue, Desc, EDate,
Yr1,
| Yr2, Yr3, Yr4, CustName FROM tMYNonconformance ORDER BY
| tMYNonconformance.EDate DESC;--
|
| Thanks in advance
|
| deb
 
Back
Top