ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Textbox Value Changes (https://www.excelbanter.com/excel-programming/398351-textbox-value-changes.html)

Karen53

Textbox Value Changes
 
Hi,

I'm having a lot of trouble with my textbox percentages.

I am using this to save the value to the worksheet:

'Save Rental Tax
With .Cells(Choice, 8)
.HorizontalAlignment = xlCenter
.NumberFormat = "0.00%;;"
Select Case frmStoreData.txtRentalTax
Case ""
.Value = Val(frmStoreData.txtRentalTax.Value)
Case 0
.Value = frmStoreData.txtRentalTax.Value
Case Is 0
.Value = frmStoreData.txtRentalTax.Value / 100
End Select
End With

I am using this to load it into the textbox:

Me.txtRentalTax.Value = Format(.Cells(Choice, 8).Value, "0.00%")

If no change is made in that particular textbox or if the value is changed
by deleting digits, i.e. change 2.45% to 2.4% by only deleting the 5, I get a
#13 Type Mismatch error.

How would I correct this?


Thanks for your help.
--

Karen

Tom Ogilvy

Textbox Value Changes
 
Select Case frmStoreData.txtRentalTax

should probably be

Select Case val(frmStoreData.txtRentalTax)

also
Case Is 0
.Value = frmStoreData.txtRentalTax.Value / 100
End Select


should probably be

Case Is 0
.Value = val(frmStoreData.txtRentalTax.Value) / 100
End Select


--
Regards,
Tom Ogilvy


"Karen53" wrote:

Hi,

I'm having a lot of trouble with my textbox percentages.

I am using this to save the value to the worksheet:

'Save Rental Tax
With .Cells(Choice, 8)
.HorizontalAlignment = xlCenter
.NumberFormat = "0.00%;;"
Select Case frmStoreData.txtRentalTax
Case ""
.Value = Val(frmStoreData.txtRentalTax.Value)
Case 0
.Value = frmStoreData.txtRentalTax.Value
Case Is 0
.Value = frmStoreData.txtRentalTax.Value / 100
End Select
End With

I am using this to load it into the textbox:

Me.txtRentalTax.Value = Format(.Cells(Choice, 8).Value, "0.00%")

If no change is made in that particular textbox or if the value is changed
by deleting digits, i.e. change 2.45% to 2.4% by only deleting the 5, I get a
#13 Type Mismatch error.

How would I correct this?


Thanks for your help.
--

Karen


Karen53

Textbox Value Changes
 
Hi Tom,

Thank you for the quick reply.

I tried your suggestions. I errored out at the
Case = ""
so I moved that out of the select case.

Then I errored at the
Select Case Val(frmStoreData.txtRentalRax.value)
when only one digit of the value is changed or if the value wasn't changed.

If I remove the Val from the select case, I error at
Case 0
.Value = Val(frmStoreData.txtRentalTax.Value)/100

Here's the code as it stands now. I suspect the problem has to do with the
textbox already showing the value as a percentage and if it is saved back to
the sheet this way it errors out. I don't know how to get around it.

Any thoughts?


With .Cells(Choice, 8)
.HorizontalAlignment = xlCenter
.NumberFormat = "0.00%;;"
If frmStoreData.txtRentalTax = "" Then
.Value = Val(frmStoreData.txtRentalTax.Value)
Else
Select Case Val(frmStoreData.txtRentalTax)
Case 0
.Value = frmStoreData.txtRentalTax.Value
Case Is 0
.Value = Val(frmStoreData.txtRentalTax.Value) / 100
End Select
End If


Thanks for your help.
--

Karen


"Tom Ogilvy" wrote:

Select Case frmStoreData.txtRentalTax

should probably be

Select Case val(frmStoreData.txtRentalTax)

also
Case Is 0
.Value = frmStoreData.txtRentalTax.Value / 100
End Select


should probably be

Case Is 0
.Value = val(frmStoreData.txtRentalTax.Value) / 100
End Select


--
Regards,
Tom Ogilvy


"Karen53" wrote:

Hi,

I'm having a lot of trouble with my textbox percentages.

I am using this to save the value to the worksheet:

'Save Rental Tax
With .Cells(Choice, 8)
.HorizontalAlignment = xlCenter
.NumberFormat = "0.00%;;"
Select Case frmStoreData.txtRentalTax
Case ""
.Value = Val(frmStoreData.txtRentalTax.Value)
Case 0
.Value = frmStoreData.txtRentalTax.Value
Case Is 0
.Value = frmStoreData.txtRentalTax.Value / 100
End Select
End With

I am using this to load it into the textbox:

Me.txtRentalTax.Value = Format(.Cells(Choice, 8).Value, "0.00%")

If no change is made in that particular textbox or if the value is changed
by deleting digits, i.e. change 2.45% to 2.4% by only deleting the 5, I get a
#13 Type Mismatch error.

How would I correct this?


Thanks for your help.
--

Karen


Karen53

Textbox Value Changes
 
Hi,

For my data validation for the textbox, I had to use the format for it to
recognize it and work, i.e. "9.99%". Could the formating be getting in the
way of saving the data? If so, is there a way around it?

Thanks,
--

Karen


"Tom Ogilvy" wrote:

Select Case frmStoreData.txtRentalTax

should probably be

Select Case val(frmStoreData.txtRentalTax)

also
Case Is 0
.Value = frmStoreData.txtRentalTax.Value / 100
End Select


should probably be

Case Is 0
.Value = val(frmStoreData.txtRentalTax.Value) / 100
End Select


--
Regards,
Tom Ogilvy


"Karen53" wrote:

Hi,

I'm having a lot of trouble with my textbox percentages.

I am using this to save the value to the worksheet:

'Save Rental Tax
With .Cells(Choice, 8)
.HorizontalAlignment = xlCenter
.NumberFormat = "0.00%;;"
Select Case frmStoreData.txtRentalTax
Case ""
.Value = Val(frmStoreData.txtRentalTax.Value)
Case 0
.Value = frmStoreData.txtRentalTax.Value
Case Is 0
.Value = frmStoreData.txtRentalTax.Value / 100
End Select
End With

I am using this to load it into the textbox:

Me.txtRentalTax.Value = Format(.Cells(Choice, 8).Value, "0.00%")

If no change is made in that particular textbox or if the value is changed
by deleting digits, i.e. change 2.45% to 2.4% by only deleting the 5, I get a
#13 Type Mismatch error.

How would I correct this?


Thanks for your help.
--

Karen



All times are GMT +1. The time now is 04:17 PM.

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