Solved the expression you entered is too complex

Your language says it all;) You have created a spreadsheet rather than a normalized relational database. Relational databases do not have "cells". Each "cell" in a spreadsheet is an independent entity and that is why you have all those domain functions, each of which is running a separate query.
by cells i meant textbox with dcount in it :) sorry
 
You do not say what the error is? :(

I would be using Me.txtb if that is a control on the form.
i used

Code:
Private Sub Form_Current()
Select Case [RiskCode]
    Case 1: Me.txtb = "1A"
    Case 2: Me.txtb = "1B"
    Case 3: Me.txtb = "1C"
    Case 4: Me.txtb = "2A"
    Case 5: Me.txtb = "2B"
    Case 6: Me.txtb = "2C"
    Case 7: Me.txtb = "3A"
    Case 8: Me.txtb = "1D"
    Case 9: Me.txtb = "1E"
    Case 10: Me.txtb = "2D"
    Case 11: Me.txtb = "3B"
    Case 12: Me.txtb = "3C"
    Case 13: Me.txtb = "4A"
    Case 14: Me.txtb = "2E"
    Case 15: Me.txtb = "3D"
    Case 16: Me.txtb = "4B"
    Case 17: Me.txtb = "4C"
    Case 18: Me.txtb = "5A"
    Case 19: Me.txtb = "5B"
    Case 20: Me.txtb = "3E"
    Case 21: Me.txtb = "4D"
    Case 22: Me.txtb = "4E"
    Case 23: Me.txtb = "5C"
    Case 24: Me.txtb = "5D"
    Case 25: Me.txtb = "5E"
    Case Else me.txtb = "recheck"

  End Select

End Sub

and got this
1712852677465.png


and it highlighs Private Sub Form_Current()
with yellow color with an arrow

1712852759411.png
 
No, you were technically correct. They are all unbound and unrelated and each is populated by a separate query. In some situations that is necessary but not all. Your grid, for example, could be done with a subform if the underlying data is normalized.
 
i used

Code:
Private Sub Form_Current()
Select Case [RiskCode]
    Case 1: Me.txtb = "1A"
    Case 2: Me.txtb = "1B"
    Case 3: Me.txtb = "1C"
    Case 4: Me.txtb = "2A"
    Case 5: Me.txtb = "2B"
    Case 6: Me.txtb = "2C"
    Case 7: Me.txtb = "3A"
    Case 8: Me.txtb = "1D"
    Case 9: Me.txtb = "1E"
    Case 10: Me.txtb = "2D"
    Case 11: Me.txtb = "3B"
    Case 12: Me.txtb = "3C"
    Case 13: Me.txtb = "4A"
    Case 14: Me.txtb = "2E"
    Case 15: Me.txtb = "3D"
    Case 16: Me.txtb = "4B"
    Case 17: Me.txtb = "4C"
    Case 18: Me.txtb = "5A"
    Case 19: Me.txtb = "5B"
    Case 20: Me.txtb = "3E"
    Case 21: Me.txtb = "4D"
    Case 22: Me.txtb = "4E"
    Case 23: Me.txtb = "5C"
    Case 24: Me.txtb = "5D"
    Case 25: Me.txtb = "5E"
    Case Else me.txtb = "recheck"

  End Select

End Sub

and got this
View attachment 113650

and it highlighs Private Sub Form_Current()
with yellow color with an arrow

View attachment 113651
Look at the sub above the current event.
 
This would have worked:
Case Else: s = "recheck"

But MUCH better would be to look up these codes in a new table. Then it's a one-liner:
Me.txtb = Nz(DLookup(...), "recheck")
 

The Case Else is the only case statement that has code after it on the same line but not delimited by ":" - so I think it is kvetching about the Case Else statement. Besides - that red highlight - if it came from Access rather than from your personal highlighting - says THAT line is in error.
 
Code:
    Case Else txtb = "recheck"

I believe you either need a colon after Else or to put the actual assignment on a new line after Else

Of course what you really need is some sort of saved data structure that stores records of associated data together. If only the developers of Access had thought to include such a malleable structure.
 
Code:
    Case Else txtb = "recheck"

I believe you either need a colon after Else or to put the actual assignment on a new line after Else

Of course what you really need is some sort of saved data structure that stores records of associated data together. If only the developers of Access had thought to include such a malleable structure.
i added a new table with 25 IDs with primary keys and link this table with my MainTable.
1712927031489.png
1712927130301.png


so now how do u make riskSLcode to be shown in my countiniusly form. i think it should be somehting with =riskID = " & risk
 
so now how do u make riskSLcode to be shown in my countiniusly form.
Change the form's RecordSource to:
SQL:
SELECT m.*, c.riskSLcode
FROM TMain m
INNER JOIN FriskSL c
        ON m.RiskCode = c.riskSLid

Then set the ControlSource of your textbox to [riskSLcode]
 
Change the form's RecordSource to:
i have already data in sql, as it needs to display data in continius form.
1712928717153.png

how can i combine them ? i mean how can i make them work together ?

i renamed FriskSLcode to TriskSLcode as its a table not a form. sorry,
 
i just made this textbox countro sorce that field in table i created where 25 autonumbers ID (with PK) = sov \ likehood indicator
1712929283788.png


then i just added in my countiniusl form
1712929346456.png


in SQL i saw a new code
Code:
FROM TriskSL INNER JOIN Tmain ON TriskSL.riskSLid = Tmain.RiskCode;


and now it works !!!!!

look
1712929432439.png
 
But MUCH better would be to look up these codes in a new table. Then it's a one-liner:
Me.txtb = Nz(DLookup(...), "recheck")
Even better than 25 queries is a left join in the RecordSource query
 

Users who are viewing this thread

Back
Top Bottom