Checkbox to change forms record source

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
 
L

.Len B

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top