Cosmos75
Registered User.
- Local time
- Today, 16:44
- Joined
- Apr 22, 2002
- Messages
- 1,280
Am trying to create a color database. I have a form with the following textboxes
ColorID (PK - Autonumber)
ColorName (Text)
Hex (Text)
R (Number)
G (Number)
B (Number)
MSACCESSColorNumber (Number)
Added a button to a Tabular Form with the folowing code to calculate Hex and MS Access Color Number if the user changes the RGB (Red, Green, Blue) values for the color.
I get Run-time error '13': Type Mismatch for HexR =Hex(R).
I get a compile error for HerR = Hex$(R), "Type declaration character does not match declared data type" - Something to do with how I dimmed?
I've tried
- Dim R as Single/Double
- Dim HexR as String/Double/Single
All combinations don't work.
What am I missing??
I have an appened query that has this formula that works.
HEXCalc: "#" & IIf(Len(Hex([R]))=1,0 & Hex([R]),Hex([R])) & IIf(Len(Hex([G]))=1,0 & Hex([G]),Hex([G])) & IIf(Len(Hex())=1,0 & Hex(),Hex())
ColorID (PK - Autonumber)
ColorName (Text)
Hex (Text)
R (Number)
G (Number)
B (Number)
MSACCESSColorNumber (Number)
Added a button to a Tabular Form with the folowing code to calculate Hex and MS Access Color Number if the user changes the RGB (Red, Green, Blue) values for the color.
Code:
Dim HEXCalc As String
Dim MSAccNumCalc As Variant
Dim R As Variant
Dim G As Variant
Dim B As Variant
Dim HexR As String
Dim HexG As String
Dim HexB As String
R = Me.R.Value
G = Me.G.Value
B = Me.B.Value
HexR = Hex(R)
HexG = Hex(G)
HexB = Hex(B)
HEXCalc = "#" & IIf(Len(HexR) = 1, "0" & HexR, HexR) &_
IIf(Len(HexG) = 1, "0" & HexG, HexG) & IIf(Len(HexB) = 1, "0" & HexB, HexB)
MSAccNumCalc = RGB(R, G, B)
Me.Hex = HEXCalc
Me.MSACCESSColorNumber = MSAccNumCalc
I get a compile error for HerR = Hex$(R), "Type declaration character does not match declared data type" - Something to do with how I dimmed?
I've tried
- Dim R as Single/Double
- Dim HexR as String/Double/Single
All combinations don't work.
What am I missing??
I have an appened query that has this formula that works.
HEXCalc: "#" & IIf(Len(Hex([R]))=1,0 & Hex([R]),Hex([R])) & IIf(Len(Hex([G]))=1,0 & Hex([G]),Hex([G])) & IIf(Len(Hex())=1,0 & Hex(),Hex())