Solved the expression you entered is too complex (1 Viewer)

TipsyWolf

Member
Local time
Today, 20:50
Joined
Mar 20, 2024
Messages
112
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
 

TipsyWolf

Member
Local time
Today, 20:50
Joined
Mar 20, 2024
Messages
112
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
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 13:50
Joined
Feb 19, 2002
Messages
43,308
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.
 

Gasman

Enthusiastic Amateur
Local time
Today, 18:50
Joined
Sep 21, 2011
Messages
14,326
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.
 

tvanstiphout

Active member
Local time
Today, 10:50
Joined
Jan 22, 2016
Messages
224
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_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 12:50
Joined
Feb 28, 2001
Messages
27,196

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.
 

plog

Banishment Pending
Local time
Today, 12:50
Joined
May 11, 2011
Messages
11,648
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.
 

TipsyWolf

Member
Local time
Today, 20:50
Joined
Mar 20, 2024
Messages
112
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
 

cheekybuddha

AWF VIP
Local time
Today, 18:50
Joined
Jul 21, 2014
Messages
2,281
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]
 

TipsyWolf

Member
Local time
Today, 20:50
Joined
Mar 20, 2024
Messages
112
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,
 

TipsyWolf

Member
Local time
Today, 20:50
Joined
Mar 20, 2024
Messages
112
YEAH ! i made it !
u guys helped me a lot. it was so easy actually
1712929160191.png
 

TipsyWolf

Member
Local time
Today, 20:50
Joined
Mar 20, 2024
Messages
112
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
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 13:50
Joined
Feb 19, 2002
Messages
43,308
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

Top Bottom