not working, cant trace (1 Viewer)

Janjang

Registered User.
Local time
Today, 20:56
Joined
Oct 17, 2005
Messages
80
Help plz

Code:
If Forms!f_Main.Coverage = "Comprehensive" Then
 If Forms!f_Main.CC = "0 - 1400 cc" Then
    Forms!f_Main.BasiPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 225.2
       ElseIf Forms!f_Main.CC = "1401 - 1650 cc" Then
          Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 251.5
          ElseIf Forms!f_Main.CC = "1651 - 2200 cc" Then
                 Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 277.9
                 ElseIf Forms!f_Main.CC = "2201 - 3050 cc" Then
                        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 304.2
                        ElseIf Forms!f_Main.CC = "3051 - 4100 cc" Then
                               Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 330.5
                               ElseIf Forms!f_Main.CC = "4101 - 4250 cc" Then
                                      Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 356.8
                                      ElseIf Forms!f_Main.CC = "4251 - 4400 cc" Then
                                             Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 383.2
                                             ElseIf Forms!f_Main.CC = "4401cc  - above" Then
                                                    Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 409.5
                                                    ElseIf Forms!f_Main.CC = "0 - 50 cc" Then
                                                           Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * 1.75 + 84
                                                           ElseIf Forms!f_Main.CC = "51 - 100 cc" Then
                                                                  Forms!f_mainn.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 1100 * 1.75 + 107
                                                                  ElseIf Forms!f_Main.CC = "101 - 125 cc" Then
                                                                         Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * 1.75 + 130
                                                                         ElseIf Forms!f_Main.CC = "126 - 225 cc" Then
                                                                                Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 1100 * 1.75 + 147.3
                                                                                ElseIf Forms!f_Main.CC = "226 - 350 cc" Then
                                                                                       Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 1100 * 1.75 + 187.5
                                                                                       ElseIf Forms!f_Main.CC = "351 - 500 cc" Then
                                                                                              Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * 1.75 + 216.3
                                                                                              ElseIf Forms!f_Main.CC = "501 cc - above" Then
                                                                                                     Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * 1.75 + 245
    End If
ElseIf Forms!form_quotation.Coverage = "3rd Party" Then
 If Forms!f_Main.CC = "0 - 1400 cc" Then
   Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 72
   ElseIf Forms!f_Main.CC = "1401 - 1650 cc" Then
          Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 81
          ElseIf Forms!f_Main.CC = "1651 - 2200 cc" Then
                 Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 90
                 ElseIf Forms!f_Main.CC = "2201 - 3050 cc" Then
                        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 99
                        ElseIf Forms!f_Main.CC = "3051 - 4100 cc" Then
                               Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 108
                               ElseIf Forms!f_Main.CC = "4101 - 4250 cc" Then
                                      Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 117
                                      ElseIf Forms!f_Main.CC = "4251 - 4400 cc" Then
                                             Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 126
                                             ElseIf Forms!f_Main.CC = "4401cc  - above" Then
                                                    Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 135
                                                    ElseIf Forms!f_Main.CC = "0 - 50 cc" Then
                                                       Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * 1.75 + 40.5
                                                       ElseIf Forms!f_Main.CC = "51 - 100 cc" Then
                                                              Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * 1.75 + 48.6
                                                              ElseIf Forms!f_Main.CC = "101 - 125 cc" Then
                                                                     Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * 1.75 + 54.75
                                                                     ElseIf Forms!f_Main.CC = "126 - 225 cc" Then
                                                                            Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * 1.75 + 66.9
                                                                            ElseIf Forms!f_Main.CC = "226 - 350 cc" Then
                                                                                   Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * 1.75 + 85.05
                                                                                   ElseIf Forms!f_Main.CC = "351 - 500 cc" Then
                                                                                          Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * 1.75 + 97.2
                                                                                          ElseIf f_Main.CC = "501 cc - above" Then
                                                                                                 Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * 1.75 + 109.35

End If
End If
 

Oldsoftboss

AWF VIP
Local time
Today, 22:56
Joined
Oct 28, 2001
Messages
2,499
I have done a similar thing, I used Case select, a bit easier to debug
 

Janjang

Registered User.
Local time
Today, 20:56
Joined
Oct 17, 2005
Messages
80
Case.. hmmm.. but is it need to make new module or i can type directly there?
 

Oldsoftboss

AWF VIP
Local time
Today, 22:56
Joined
Oct 28, 2001
Messages
2,499
If Forms!f_Main.Coverage = "Comprehensive" Then

Select Case Forms!f_Main.CC
Case "0 - 1400 cc"
Forms!f_Main.BasiPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 225.2
Case "1401 - 1650 cc"
Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 251.5
Case "1651 - 2200 cc"
Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 277.9
Case "2201 - 3050 cc"
Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 304.2
Case "3051 - 4100 cc"
Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 330.5
Case "4101 - 4250 cc"
Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 356.8
Case "4251 - 4400 cc"
Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 383.2
Case "4401cc - above"
Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 409.5
Case "0 - 50 cc"
Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * 1.75 + 84
Case "51 - 100 cc"
Forms!f_mainn.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 1100 * 1.75 + 107
Case "101 - 125 cc"
Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * 1.75 + 130
Case "126 - 225 cc"
Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 1100 * 1.75 + 147.3
Case "226 - 350 cc"
Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 1100 * 1.75 + 187.5
Case "351 - 500 cc"
Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * 1.75 + 216.3
Case "501 cc - above"
Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * 1.75 + 245
End Select

ElseIf Forms!form_quotation.Coverage = "3rd Party" Then
Select Case Forms!f_Main.CC
Case "0 - 1400 cc"
Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 72
Case "1401 - 1650 cc"
Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 81
Case "1651 - 2200 cc"
Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 90
Case "2201 - 3050 cc"
Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 99
Case "3051 - 4100 cc"
Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 108
Case "4101 - 4250 cc"
Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 117
Case "4251 - 4400 cc"
Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 126
Case "4401cc - above"
Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 135
Case "0 - 50 cc"
Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * 1.75 + 40.5
Case "51 - 100 cc"
Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * 1.75 + 48.6
Case "101 - 125 cc"
Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * 1.75 + 54.75
Case "126 - 225 cc"
Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * 1.75 + 66.9
Case "226 - 350 cc"
Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * 1.75 + 85.05
Case "351 - 500 cc"
Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * 1.75 + 97.2
Case "501 cc - above"
Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * 1.75 + 109.35
End Select
End If
 

Oldsoftboss

AWF VIP
Local time
Today, 22:56
Joined
Oct 28, 2001
Messages
2,499
I worry about the line:

"0 - 1400 cc"

Is this a look up field (combo box) or do you type values into a text box?

It should be a lookup field to get consistancy.

Also remember the arithmatic is hard coded, so if the rates ever change, a lot of rework is involved . These should aslo be looking up references.
 

namliam

The Mailman - AWF VIP
Local time
Today, 14:56
Joined
Aug 11, 2003
Messages
11,695
This should be a lot more readable and is a more logical way of representing a ElseIf structure
Code:
If Forms!f_Main.Coverage = "Comprehensive" Then
    If Forms!f_Main.CC = "0 - 1400 cc" Then
        Forms!f_Main.BasiPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 225.2
    ElseIf Forms!f_Main.CC = "1401 - 1650 cc" Then
        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 251.5
    ElseIf Forms!f_Main.CC = "1651 - 2200 cc" Then
        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 277.9
    ElseIf Forms!f_Main.CC = "2201 - 3050 cc" Then
        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 304.2
    ElseIf Forms!f_Main.CC = "3051 - 4100 cc" Then
        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 330.5
    ElseIf Forms!f_Main.CC = "4101 - 4250 cc" Then
        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 356.8
    ElseIf Forms!f_Main.CC = "4251 - 4400 cc" Then
        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 383.2
    ElseIf Forms!f_Main.CC = "4401cc  - above" Then
        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 409.5
    ElseIf Forms!f_Main.CC = "0 - 50 cc" Then
        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * 1.75 + 84
    ElseIf Forms!f_Main.CC = "51 - 100 cc" Then
        Forms!f_mainn.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 1100 * 1.75 + 107
    ElseIf Forms!f_Main.CC = "101 - 125 cc" Then
        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * 1.75 + 130
    ElseIf Forms!f_Main.CC = "126 - 225 cc" Then
        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 1100 * 1.75 + 147.3
    ElseIf Forms!f_Main.CC = "226 - 350 cc" Then
        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 1100 * 1.75 + 187.5
    ElseIf Forms!f_Main.CC = "351 - 500 cc" Then
        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * 1.75 + 216.3
    ElseIf Forms!f_Main.CC = "501 cc - above" Then
        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * 1.75 + 245
    End If
ElseIf Forms!form_quotation.Coverage = "3rd Party" Then
    If Forms!f_Main.CC = "0 - 1400 cc" Then
        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 72
    ElseIf Forms!f_Main.CC = "1401 - 1650 cc" Then
        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 81
    ElseIf Forms!f_Main.CC = "1651 - 2200 cc" Then
        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 90
    ElseIf Forms!f_Main.CC = "2201 - 3050 cc" Then
        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 99
    ElseIf Forms!f_Main.CC = "3051 - 4100 cc" Then
        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 108
    ElseIf Forms!f_Main.CC = "4101 - 4250 cc" Then
        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 117
    ElseIf Forms!f_Main.CC = "4251 - 4400 cc" Then
        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 126
    ElseIf Forms!f_Main.CC = "4401cc  - above" Then
        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * 0.026 + 135
    ElseIf Forms!f_Main.CC = "0 - 50 cc" Then
        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * 1.75 + 40.5
    ElseIf Forms!f_Main.CC = "51 - 100 cc" Then
        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * 1.75 + 48.6
    ElseIf Forms!f_Main.CC = "101 - 125 cc" Then
        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * 1.75 + 54.75
    ElseIf Forms!f_Main.CC = "126 - 225 cc" Then
        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * 1.75 + 66.9
    ElseIf Forms!f_Main.CC = "226 - 350 cc" Then
        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * 1.75 + 85.05
    ElseIf Forms!f_Main.CC = "351 - 500 cc" Then
        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * 1.75 + 97.2
    ElseIf f_Main.CC = "501 cc - above" Then
        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * 1.75 + 109.35
    
    End If
End If

Note that you are using "/ 100 * 1.75" and "0.026" which is both 1 way of calculating %. But stick to 1 of them.... dont use both this adds to unreadability. Use a "convention" and stick by it.

Because you allways have "ElseIf Forms!f_Main.CC" a Select Case would be more efficient. Even so I would NOT solve this using ether a If structure nore use a Select case. I would use a table to store the names you need and the variables to calculate.
It really is much more maintenance friendly than using these hardcoded values...

The table would be something like
Code:
Name         Multi Comp  NoComp
0 - 1400 cc  2.6   225.2  72
0 - 50 cc    1.75   84    40.5
Then in the code you would do something like:
Code:
sub something
    dim rst as DAO.Recordset
    Set rst = currentdb.openrecordset("Select * from [AboveTable] where [name] = """ & Forms!f_Main.CC & """")
    If Forms!f_Main.Coverage = "Comprehensive" Then
        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * rst!Multi + rst!Comp
    else
        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * rst!Multi + rst!NoComp
    end if
    set rst = nothing
end sub
This seems a little more managable to me ;)

Edit: Some typo's and changed the table look...
 
Last edited:

Oldsoftboss

AWF VIP
Local time
Today, 22:56
Joined
Oct 28, 2001
Messages
2,499
If Forms!f_Main.Coverage = "Comprehensive" Then


ElseIf Forms!form_quotation.Coverage = "3rd Party" Then


Is this correct ?
Seems to be pointing to 2 different forms.

Dave
 

Janjang

Registered User.
Local time
Today, 20:56
Joined
Oct 17, 2005
Messages
80
yup u right
1st conditoin is either comprehensive or 3rd party

and i make "cc" value thingy wit combobox
 

namliam

The Mailman - AWF VIP
Local time
Today, 14:56
Joined
Aug 11, 2003
Messages
11,695
So are you getting anywhere in solving this?
 

Janjang

Registered User.
Local time
Today, 20:56
Joined
Oct 17, 2005
Messages
80
namliam said:
Note that you are using "/ 100 * 1.75" and "0.026" which is both 1 way of calculating %. But stick to 1 of them.... dont use both this adds to unreadability. Use a "convention" and stick by it.

Because you allways have "ElseIf Forms!f_Main.CC" a Select Case would be more efficient. Even so I would NOT solve this using ether a If structure nore use a Select case. I would use a table to store the names you need and the variables to calculate.
It really is much more maintenance friendly than using these hardcoded values...

The table would be something like
Code:
Name         Multi Comp  NoComp
0 - 1400 cc  2.6   225.2  72
0 - 50 cc    1.75   84    40.5
Then in the code you would do something like:
Code:
sub something
    dim rst as DAO.Recordset
    Set rst = currentdb.openrecordset("Select * from [AboveTable] where [name] = """ & Forms!f_Main.CC & """")
    If Forms!f_Main.Coverage = "Comprehensive" Then
        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * rst!Multi + rst!Comp
    else
        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * rst!Multi + rst!NoComp
    end if
    set rst = nothing
end sub
This seems a little more managable to me ;)


wonder y use rst!Comp and NoComp? i think u not lok at it carefully... that is not a fix value, it depand on cc value..
 

Janjang

Registered User.
Local time
Today, 20:56
Joined
Oct 17, 2005
Messages
80
stil not working...

it not calculate at all


help me plz
 

Attachments

  • Insurance.zip
    132.6 KB · Views: 130

namliam

The Mailman - AWF VIP
Local time
Today, 14:56
Joined
Aug 11, 2003
Messages
11,695
Janjang said:
wonder y use rst!Comp and NoComp? i think u not lok at it carefully... that is not a fix value, it depand on cc value..
I not look at it carefully??? Just cause you dont (fully) understand it doesnt mean I didnt look carefully :mad:

If you look carefully I made a table to contain your precious CC values. This table contains the Comp and NoComp values as well as the Multiplyer value.

Even better you allready have a table containing the CC values. Simply add the extra values you are using in the Select Case and you are done...

Regards
 

Janjang

Registered User.
Local time
Today, 20:56
Joined
Oct 17, 2005
Messages
80
sorry if it seems rude.. but dcan u explain it ?
 

namliam

The Mailman - AWF VIP
Local time
Today, 14:56
Joined
Aug 11, 2003
Messages
11,695
You add 3 columns to your excisting table containing the CC values...
These 3 columns you use to store the values you are now using in the Select Case... i.e.
Code:
Name         Multi Comp  NoComp
0 - 1400 cc  2.6   225.2  72
0 - 50 cc    1.75   84    40.5

Now you can use code that looks like this:
Code:
sub something
    dim rst as DAO.Recordset
    Set rst = currentdb.openrecordset("Select * from [AboveTable] where [name] = """ & Forms!f_Main.CC & """")
    If Forms!f_Main.Coverage = "Comprehensive" Then
        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * rst!Multi + rst!Comp
    else
        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * rst!Multi + rst!NoComp
    end if
    set rst = nothing
end sub
to calculate the BasicPremium you need.

You may have to change it a little, table names and/or column names to which you will be using....
 

Janjang

Registered User.
Local time
Today, 20:56
Joined
Oct 17, 2005
Messages
80
not working at all

Code:
Private Sub Command51_Click()
    
    Dim rst As DAO.Recordset
    Set rst = CurrentDb.OpenRecordset("Select * from [t_CC] where [CC] = """ & Forms!f_Main.CC & """")
    If Forms!f_Main.Coverage = "Comprehensive" Then
        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) * rst!Multi + rst!Comprehensive
    Else
        Forms!f_Main.BasicPremium = (Forms!f_Main.SumInsured - 1000) / 100 * rst!Multi + rst!rdParty
    End If
    Set rst = Nothing
    
End Sub
 

Attachments

  • Insurance.zip
    132.6 KB · Views: 128

namliam

The Mailman - AWF VIP
Local time
Today, 14:56
Joined
Aug 11, 2003
Messages
11,695
It is not working for you because your field CC on your f_main (check out this recent thread about naming conventions) is a combo box. This doesnt store the text "0 - 1400 cc" but the value of its Key, 1.

So change the query

Set rst = CurrentDb.OpenRecordset("Select * from [t_CC] where [CC] = """ & Forms!f_Main.CC & """")

to this:

Set rst = CurrentDb.OpenRecordsetSelect * from [t_CC] where [CC_ID] = " & Me.CC & "")

and it should work. Since you are using the code from within the same form where the controls (inputboxes) are you can use Me. instead of Forms!f_Main. which is much easier to work with.

Greets & GL
 

Janjang

Registered User.
Local time
Today, 20:56
Joined
Oct 17, 2005
Messages
80
done.. but at If.. Else expression have error

ive change it to this code

Code:
    Dim strRS As String
    Dim rst As DAO.Recordset
    
    strRS = " Select * from [t_CC] WHERE [CC] ='" & Me.CC & "' "
    
    Set rst = CurrentDb.OpenRecordset(strRS)
    
    If Forms!f_Main.Coverage = "Comprehensive" Then
        Me.BasicPremium = (Me.SumInsured - 1000) * rst!Multi + rst!Comprehensive ' error in here
    Else
        Me.BasicPremium = (Me.SumInsured - 1000) / 100 * rst!Multi + rst!rdParty ' error here too maybe
    End If
    Set rst = Nothing
 

namliam

The Mailman - AWF VIP
Local time
Today, 14:56
Joined
Aug 11, 2003
Messages
11,695
NO NO NO... Me.CC returns a NUMBER not a string...

Recheck my previous post and see where you went wrong with your query....

Greets from a Sunny Amsterdam :)
 

Users who are viewing this thread

Top Bottom