Change Label Background Color with VBScript - html

I have a HTA form where input type labels are set to background-color: LightGray; in the head CSS, and I would like to change the background color to another color during runtime based on a condition with VBScript. Condition code is fine (If... Then... End If)
Let's say the control's ID is "controlid".
I have tried stuff like
controlid.style.BackColor = RGB(0,0,0)
controlid.style.bgColor = RGB(0,0,0)
controlid.style.BackColor = "0,0,0"
controlid.style.bgColor = "0,0,0"
controlid.BackColor = RGB(0,0,0)
controlid.bgColor = RGB(0,0,0)
controlid.BackColor = "0,0,0"
controlid.bgColor = "0,0,0"
etcetera.
Google is not playing nice. Is there a way to do this?

Related

Shadow with transparent background in Jetpack Compose

Can anyone explain this?
And how to make the center rectangle with the color of the background disappear?
the result here
I've tried many ways but still can't understand the logic here. (different from Flutter UI)
Box(
modifier = Modifier
.fillMaxWidth()
.shadow(elevation = 3.dp, shape = RoundedCornerShape(28.dp))
.background(
MaterialTheme.colors.primary.copy(alpha = 0.8f),
shape = RoundedCornerShape(28.dp)
)
.padding(16.dp)
)
use like this -
.background(
MaterialTheme.colors.primary.copy(alpha = 0.8f).compositeOver(Color.White),
shape = RoundedCornerShape(28.dp)
)
the background basically shows for elevation and shadow, if you remove them then it will be gone, since you are using transparent color that's why you are seeing this. but make the color solid but light using compositeOver , then it will work fine.

MS Access Toggle Button background

Is it possible to totally remove the background color and the border of a toggle button in Access? As shown in the Imgur picture, I'd like to remove the grey-ish background and the border of the button totally so I'd keep the white icon (that list icon) only. Would that even be possible?
I am sure this is related to your other question at MS Access ToggleButton Picture change.
Use an Image control with embedded image and this code (note declaration of public variable in header):
Option Compare Database
Option Explicit
Public booMenu
Sub timeout(duration_ms As Double)
Dim Start_Time As Double
Start_Time = Timer
Do
DoEvents
Loop Until (Timer - Start_Time) >= duration_ms
End Sub
Private Sub Image5_Click()
Dim x As Integer
booMenu = Not booMenu
Me.Menu.Visible = True
Do
DoEvents
Me.Menu.Width = Me.Menu.Width + IIf(booMenu, 200, -200)
Me.Menu.Left = Me.Menu.Left - IIf(booMenu, 200, -200)
Me.Image5.Left = Me.Image5.Left - IIf(booMenu, 200, -200)
timeout (0.01)
x = x + 1
Loop Until x = 10
Me.Menu.Visible = booMenu
End Sub
I managed to find (kind of) a solution to this. The solution was to change the following parameters:
Use Theme = No;
BackColor = Form Color;
Pressed Back Color = Form Color
Eventually, it provides an effect very similar to the one that I was trying to achieve.

Access VBA Back Color Gradient For Label/Shape

I'm looking for a way in Access VBA to set the backcolor of a label, shaped, etc as a gradient. I'm currently applying solid colors but was hoping there is a way to accomplish this via a gradient.
Here is how I'm currently applying a back color in Access:
Label2.BackColor = RGB(119, 49, 65)
Here was the code I was using in Excel, to fill a cell as a gradient, worked well. However, I'm not sure exactly how Access VBA would work. Suggestions to point me in the right direction?
Range("D14").Select
With Selection.Interior
.Pattern = xlPatternLinearGradient
.Gradient.Degree = 0
.Gradient.ColorStops.Clear
End With
With Selection.Interior.Gradient.ColorStops.Add(0)
.Color = 2786997
.TintAndShade = 0
End With
With Selection.Interior.Gradient.ColorStops.Add(1)
.Color = 1447704
.TintAndShade = 0
End With
A Label cannot have a gradient background.
If you want to set the gradient on a button you can do that similar to before.
button.Gradient = 12

Format fields in subform records using VBA

I'm trying to use VBA to format some unbound textboxes I've added to the rows on a subform set to continuous view.
The VBA looks at the bound text boxes associated with the subform's underlying RecordSource and then formats the unbound textboxes I've added based on the data.
Here's some simplified code:
Public Sub ApplyFormat()
If Forms!tblEnrolments!tblEnrolments_Jobs_sub!Start = 1 Then
Forms!tblEnrolments!tblEnrolments_Jobs_sub!txtStart.BackColor = RGB(65, 138, 179)
Forms!tblEnrolments!tblEnrolments_Jobs_sub!txtStart.ForeColor = RGB(255, 255, 255)
Forms!tblEnrolments!tblEnrolments_Jobs_sub!txtStart = "Start Forms"
ElseIf Forms!tblEnrolments!tblEnrolments_Jobs_sub!Start = 0 Then
Forms!tblEnrolments!tblEnrolments_Jobs_sub!txtStart.BackColor = RGB(216, 216, 216)
Forms!tblEnrolments!tblEnrolments_Jobs_sub!txtStart.ForeColor = RGB(166, 166, 166)
Forms!tblEnrolments!tblEnrolments_Jobs_sub!txtStart = "None"
End If
If Forms!tblEnrolments!tblEnrolments_Jobs_sub!End = 1 Then
Forms!tblEnrolments!tblEnrolments_Jobs_sub!txtEnd.BackColor = RGB(8, 164, 71)
Forms!tblEnrolments!tblEnrolments_Jobs_sub!txtEnd.ForeColor = RGB(255, 255, 255)
Forms!tblEnrolments!tblEnrolments_Jobs_sub!txtEnd = "End Forms"
ElseIf Forms!tblEnrolments!tblEnrolments_Jobs_sub!End = 0 Then
Forms!tblEnrolments!tblEnrolments_Jobs_sub!txtEnd.BackColor = RGB(216, 216, 216)
Forms!tblEnrolments!tblEnrolments_Jobs_sub!txtEnd.ForeColor = RGB(166, 166, 166)
Forms!tblEnrolments!tblEnrolments_Jobs_sub!txtEnd = "None"
End If
End Sub
Private Sub Form_Activate()
ApplyFormat
End Sub
Private Sub Form_Current()
ApplyFormat
End Sub
So I have a public sub called ApplyFormat that looks at the data in the bound textboxes and then applies formatting (changes the textbox background colour, font colour and text data). This is then called from the Current event (so formats are applied whenever a record is loaded) and the Activate event (because the main form will open other forms whilst still being open and may get focus again when those other forms close).
Unfortunately, records below record 1 in the subform are not being formatted based on data in their record; they are just simply duplicating the formatting applied at the first record.
For example:
Here EnrolID "1" has 2 attached jobs showing in the subform. The first record is formatting correct as per the code above, i.e. the bound "Start" text box is 1 so the unbound text box next to it is being formatted as blue with white text and the string "Start Forms".
In the second record however, the "Start" text box is 0, which should format the unbound text box next to it as grey with the string "None". But as you can see it's just copying the formatting of the first record. Furthermore, the bound text box "End" has a value of 1, which should make the unbound text box next to it green with white text and the string "End Forms".
Is it possible it possible to achieve the effect I'm going for via VBA? I don't think I can use conditional formatting as I want the unbound text boxes to show data such as "Start Forms" and "End Forms" depending on their bound text box counterpart.
You cannot use unbound fields for that: Unbounds fields in continuous forms always have the same formatting in all rows. It's an unfortunate limitation.
Fortunately, there is another option: You can make a bound field, with a ControlSource that calls a user-defined function. For example, in the Form desginer, create a text box and set its "control source" property to = Iif([Start] = 1, "Start Forms", "None") (including the = sign at the start). The formatting would have to be done through conditional formatting.
If you need more complicated logic to determine the text to be shown, you can set the control source to = myCustomFunction([any], [dbfields], [I], [need]) and have the VBA code return the text to be shown.

Corona widget.newButton change defaultFile

Considering I am defining some button like the following:
-- title button
titleButton = widget.newButton{
label="",
width=265, height=70,
defaultFile = "images/title.png",
overFile = "images/title_clicked.png",
onEvent = handlePlayEvent
}
titleButton:setReferencePoint(display.CenterReferencePoint)
titleButton.x = display.contentWidth / 2
titleButton.y = display.contentHeight / 4
Is it possible to modify the button's defaultFile and overFile after creation from some other function.
I have searched the docs and couldn't find anything. Any tip would be appreciated
You can't change defaultFile and overFile after its creation.
Like display.newImage(), you can't directly change the image itself unless it is an image sheet.
But you can use image sheet as a button. You can change its frame whenever you want.