ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Microsoft error (https://www.excelbanter.com/excel-programming/428580-microsoft-error.html)

alvin Kuiper

Microsoft error
 
Hi!
I have this code:
Private Sub ComboBox3_Click()
Range("priskalk!$L$12").Value = ComboBox3.Value
pr_ekstrapris
pr_pakkepris
pr_hotelpris
If hotelpris < "" Then
txt_hotel.Text = hotelpris
txt_hotel.Enabled = False
End If
End Sub
And its working

But if i change the code into a IF then i get this Microsoft error
and excel crass

The code i use is:
Private Sub ComboBox3_Click()

Range("priskalk!$L$12").Value = ComboBox3.Value
If fradato.Text < "" And Tildato.Text < "" Then
pr_ekstrapris
pr_pakkepris
pr_hotelpris
If hotelpris < "" Then
txt_hotel.Text = hotelpris
txt_hotel.Enabled = False
End If
End If
End Sub
And the only diff between the first code and yhe next is:

If fradato.Text < "" And Tildato.Text < "" Then

I don't understand why ?



Jacob Skaria

Microsoft error
 
Let us know what the error is and in which line

Few suggestions
1. Declare your variables and use 'Option Explicit' statement
2. Getinto break mode F8 and anlayse in which line in breaks

If this post helps click Yes
---------------
Jacob Skaria


"alvin Kuiper" wrote:

Hi!
I have this code:
Private Sub ComboBox3_Click()
Range("priskalk!$L$12").Value = ComboBox3.Value
pr_ekstrapris
pr_pakkepris
pr_hotelpris
If hotelpris < "" Then
txt_hotel.Text = hotelpris
txt_hotel.Enabled = False
End If
End Sub
And its working

But if i change the code into a IF then i get this Microsoft error
and excel crass

The code i use is:
Private Sub ComboBox3_Click()

Range("priskalk!$L$12").Value = ComboBox3.Value
If fradato.Text < "" And Tildato.Text < "" Then
pr_ekstrapris
pr_pakkepris
pr_hotelpris
If hotelpris < "" Then
txt_hotel.Text = hotelpris
txt_hotel.Enabled = False
End If
End If
End Sub
And the only diff between the first code and yhe next is:

If fradato.Text < "" And Tildato.Text < "" Then

I don't understand why ?



alvin Kuiper

Microsoft error
 
Yes but thats the problem
I don't get what error, i just get this microsoft error, where i can say yes
to send the error.

But i solve it this way:
If fradato.Text < "" And Tildato.Text < "" Then
i change to
If formname.fradato.Text < "" And formname.Tildato.Text < "" Then

Alvin

"Jacob Skaria" skrev:

Let us know what the error is and in which line

Few suggestions
1. Declare your variables and use 'Option Explicit' statement
2. Getinto break mode F8 and anlayse in which line in breaks

If this post helps click Yes
---------------
Jacob Skaria


"alvin Kuiper" wrote:

Hi!
I have this code:
Private Sub ComboBox3_Click()
Range("priskalk!$L$12").Value = ComboBox3.Value
pr_ekstrapris
pr_pakkepris
pr_hotelpris
If hotelpris < "" Then
txt_hotel.Text = hotelpris
txt_hotel.Enabled = False
End If
End Sub
And its working

But if i change the code into a IF then i get this Microsoft error
and excel crass

The code i use is:
Private Sub ComboBox3_Click()

Range("priskalk!$L$12").Value = ComboBox3.Value
If fradato.Text < "" And Tildato.Text < "" Then
pr_ekstrapris
pr_pakkepris
pr_hotelpris
If hotelpris < "" Then
txt_hotel.Text = hotelpris
txt_hotel.Enabled = False
End If
End If
End Sub
And the only diff between the first code and yhe next is:

If fradato.Text < "" And Tildato.Text < "" Then

I don't understand why ?



Jacob Skaria

Microsoft error
 
You can even try

Me.fradato.Text
--
If this post helps click Yes
---------------
Jacob Skaria


"alvin Kuiper" wrote:

Yes but thats the problem
I don't get what error, i just get this microsoft error, where i can say yes
to send the error.

But i solve it this way:
If fradato.Text < "" And Tildato.Text < "" Then
i change to
If formname.fradato.Text < "" And formname.Tildato.Text < "" Then

Alvin

"Jacob Skaria" skrev:

Let us know what the error is and in which line

Few suggestions
1. Declare your variables and use 'Option Explicit' statement
2. Getinto break mode F8 and anlayse in which line in breaks

If this post helps click Yes
---------------
Jacob Skaria


"alvin Kuiper" wrote:

Hi!
I have this code:
Private Sub ComboBox3_Click()
Range("priskalk!$L$12").Value = ComboBox3.Value
pr_ekstrapris
pr_pakkepris
pr_hotelpris
If hotelpris < "" Then
txt_hotel.Text = hotelpris
txt_hotel.Enabled = False
End If
End Sub
And its working

But if i change the code into a IF then i get this Microsoft error
and excel crass

The code i use is:
Private Sub ComboBox3_Click()

Range("priskalk!$L$12").Value = ComboBox3.Value
If fradato.Text < "" And Tildato.Text < "" Then
pr_ekstrapris
pr_pakkepris
pr_hotelpris
If hotelpris < "" Then
txt_hotel.Text = hotelpris
txt_hotel.Enabled = False
End If
End If
End Sub
And the only diff between the first code and yhe next is:

If fradato.Text < "" And Tildato.Text < "" Then

I don't understand why ?




All times are GMT +1. The time now is 10:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com