Sorting form thru code


Joined
Mar 11, 2014
Messages
2
Reaction score
0
Hello all,
I am currently trying to convert an older access 2003 logbook database over to 2010, but doing it from scratch. I'm following a similar structure from a functionality standpoint as the older version, so I assumed that some of the programming would be the same with minor tweaking. Being old and rusty on access I wasn't surprise to be shown otherwise.

Basically when the DB loads, the user picks the line or lines (could be 1 or up to 35) they want to see records of, press next, and a new form pops up with the appropriate records. Here's a sample of the old code:

-----------------------------------

Private Sub cmdGetSelected_Click()

On Error GoTo Err_cmdGetSelected_Click

Dim DocName As String
Dim Clause As String
Dim cnst As String
Clause = "tblentries.Area = " & Chr(34) & Chr(34)
cnst = " OR tblentries.area = " & Chr(34)

If (Me![cbx70] = True) Then Clause = Clause & cnst & "70" & Chr(34)
If (Me![cbx71] = True) Then Clause = Clause & cnst & "71" & Chr(34)
If (Me![cbx72] = True) Then Clause = Clause & cnst & "72" & Chr(34)
If (Me![cbx74] = True) Then Clause = Clause & cnst & "74" & Chr(34)
If (Me![cbx75] = True) Then Clause = Clause & cnst & "75" & Chr(34)
If (Me![cbx77] = True) Then Clause = Clause & cnst & "77" & Chr(34)
If (Me![cbx78] = True) Then Clause = Clause & cnst & "78" & Chr(34)

Err_cmdGetSelected_Click:
MsgBox Error$
Resume Exit_cmdGetSelected_Click

DocName = "frmNavigation"
DoCmd.OpenForm DocName, , , Clause

Exit_cmdGetSelected_Click:
Exit Sub


End Sub

-----------------------------
The only thing I left out is the other 30 lines of code for the other lines to be selected...and they are identical other than the actual label.

This code works flawlessly in 2003, but not in 2010. I have some coding experience, but not enough to understand how this works, and how to modify it to work in the new version of access. Any help on this would be greatly appreciated!

-LC
 
Ad

Advertisements

Joined
Mar 11, 2014
Messages
2
Reaction score
0
Here's a different spin I was thinking on this. Using this similar code, how could I input only what is selected (true) and place it in the criteria field of a query/filter? The selection process is using check boxes.

-LC
 

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