MS Access Display images based on combo box selection in Report - image

I'm currently creating hazard labels for a chemical inventory. I want the selected pictogram image to show up based on the data from the combo box for each of the records in the report.
My inital method was to place the images on top of each other and hide them. Then have their respective images be visible due to the combo box selection. This works perfectly in a form in the Form_Current event. When you place it in Report_Current event only the selected record image would change when clicked but all the rest are blank.
The code:
If GHS_Selection_1.Value = "1" Then
expos.Visible = False
flamme.Visible = False
rondflam.Visible = False
bottle.Visible = False
skull.Visible = False
exclam.Visible = False
acid.Visible = False
silhouete.Visible = False
aquatic.Visible = False
ElseIf GHS_Selection_1.Value = "2" Then
expos.Visible = True
flamme.Visible = False
rondflam.Visible = False
bottle.Visible = False
skull.Visible = False
exclam.Visible = False
acid.Visible = False
silhouete.Visible = False
aquatic.Visible = False
ElseIf GHS_Selection_1.Value = "3" Then
expos.Visible = False
flamme.Visible = True
rondflam.Visible = False
bottle.Visible = False
skull.Visible = False
exclam.Visible = False
acid.Visible = False
silhouete.Visible = False
aquatic.Visible = False
...etc
Is there a better method for this or improvements? OLE objects or unbounded images boxes? Any advice would be appreciated. Thanks.
Edit:
In a somewhat related issue, is there a way I can fill a whole page or many pages with the same record, and another when you select a range of chemicals for printing from a subform/table from a click of a button.

Related

UIStackView can I add it with autoresizing instead of autolayout

I've tried to place UIStackView inside UIScrollView with autoresizing masks .flexibleWidth, .flexibleHeight -> i.e. stretch horizontally/vertically to fill scroll view but stack view does not appear if I changed this to autolayout code with leading/trailing/bottom/top constraints then views appear correctly
toolbar.autoresizingMask = [.flexibleWidth, .flexibleHeight]
toolbar.backgroundColor = .clear
toolbar.axis = .horizontal
toolbar.distribution = .fill
toolbar.alignment = .fill
toolbar.spacing = 8
toolbarScroll.frame = bounds
toolbarScroll.autoresizingMask = [.flexibleHeight, .flexibleWidth]
toolbarScroll.showsHorizontalScrollIndicator = false
toolbarScroll.showsVerticalScrollIndicator = false
toolbarScroll.backgroundColor = UIColor.green
toolbarScroll.addSubview(toolbar)
Here is code that if added after addSubview then toolbar show in toolbarScroll
toolbar.translatesAutoresizingMaskIntoConstraints = false
toolbar.leadingAnchor.constraint(equalTo: toolbarScroll.leadingAnchor).isActive = true
toolbar.trailingAnchor.constraint(equalTo: toolbarScroll.trailingAnchor).isActive = true
toolbar.bottomAnchor.constraint(equalTo: toolbarScroll.bottomAnchor).isActive = true
toolbar.topAnchor.constraint(equalTo: toolbarScroll.topAnchor).isActive = true
You added toolbar to toolbarScroll, but you didn't give it a frame.
toolbarScroll.addSubview(toolbar)
// just to make sure...
toolbar.translatesAutoresizingMaskIntoConstraints = true
// give the toolbar stackView a frame
toolbar.frame = toolbarScroll.bounds

Roblox Gui Toggles On/Off only on the First click

My gui turns on when touching an NPC. It shows an "Off" button. When the off button is clicked the first time, it turns off the gui by setting the frame.Visible = false and the gui.Enabled = false.
When I touch the NPC again, the gui shows, as it should. Though the button doesn't cause the properties to be set to false. I have outputted the value of frame.Visible and it prints "False", though in the Properties window, the value is shown to be "True".
What is going on here?
--NPC Script
local soldier = game.Workspace["Level6"].Soldier.Humanoid.RootPart
local player = game.Players.LocalPlayer
local function onTouch(touchPart)
if touchPart.Parent:FindFirstChild("Humanoid") then
local gui = game.Players.LocalPlayer.PlayerGui.EndScreenGui
local frame = gui.Frame
frame.Visible = true
gui.Enabled = true
print("On")
end
end
soldier.Touched:Connect(onTouch)
And here is my gui code:
local button = script.Parent
function onClicked()
local frame = button.Parent
local gui = frame.Parent
--frame.Visible = false
gui.Enabled = false
print(frame.Visible)
end
button.MouseButton1Click:Connect(onClicked)
If we do syntax higlighting we can see this:
function onClicked()
local frame = button.Parent
local gui = frame.Parent
--frame.Visible = false
gui.Enabled = false
print(frame.Visible)
end
The frame.Visible line is commented off, so it doesn't run. Remove the -- before that line and your script should be all good.

Can I prevent text highlight when I hit "return" keystroke on a NSTextField?

Before I hit "return" keystroke:
After I hit "return" keystroke:
I don't want that highlight, just want to keep it unchanged.
How can I do that?
Here is the code snippet for this text field:
let searchField = NSTextField()
searchField.isBezeled = false
searchField.drawsBackground = false
searchField.textColor = .white
searchField.focusRingType = .none
searchField.usesSingleLineMode = true
searchField.cell?.sendsActionOnEndEditing = false
searchField.target = self
searchField.action = #selector(searchAction)
Edit: Seems like it's just highlight but not a selection,because
let textEditor = window?.fieldEditor(true, for: searchField)
textEditor.selectedRange.length == 0 //length is 0

VB6 Change Background Colour of ListView Item

Refering to Change background color of listview in vb6
I tried this example and does not work as in I see no coloured rows.
I have a command button on my form that loads listview items then once that is finished I call the routine to setup the colour.
I made my picture box visible to see the expected outcome and it is as expected. So effectively setting the ListView's Picture property to the PictureBox's Image property is doing nothing for me.
Anyhow this is my code:
'pbxBG.Visible = True
If lsvPersonalisation.ListItems.Count <> 0 Then
pbxBG.Width = lsvPersonalisation.Width
pbxBG.Height = lsvPersonalisation.ListItems(1).Height * (lsvPersonalisation.ListItems.Count)
pbxBG.ScaleHeight = lsvPersonalisation.ListItems.Count
pbxBG.ScaleWidth = 1
pbxBG.DrawWidth = 1
pbxBG.Cls
Dim i As Integer
For i = 1 To lsvPersonalisation.ListItems.Count
If lsvPersonalisation.ListItems(i).Tag = "1" Then
pbxBG.Line (0, i - 1)-(1, i), &H80FFFF, BF
Else
pbxBG.Line (0, i - 1)-(1, i), &HFFFFFF, BF
End If
Next i
Else
pbxBG.Cls
End If
lsvPersonalisation.Picture = pbxBG.Image
'pbxBG.Visible = False

How to make buttons stay pressed using corona

I am trying to get my buttons to stay "pressed" once it is released. Right now I am using the improved Buttons Module for corona and I have the default image being the button looking unpressed, and the over image being replaced by an image that looks pressed.
What I am trying to do is once the button is pressed, it stays on the over image. Here is how my code is set up for the button I am testing it on.
local digButton = buttons.newButton{
default = "digButton.png",
over = "digButtonPressed.png",
onEvent = digButtonFunction,
id = "dig"
}
digButton:setReferencePoint(display.CenterReferencePoint)
digButton.x = display.contentWidth/5
digButton.y = display.contentHeight/1.9
Also, I have a function (digButtonFunction) that sets the id of this button to a variable to be used to run an if statement for when the user pushes a button following this one.
This sounds to me like what you really want is a switch. Buttons are not really designed from a UI perspective to do that. The down-state is there just to give feedback to the user that some action happened.
If it were me, I'd not use the button bit at all, but load in to images using display.newImageRect() and draw the downstate first, then the upstate. Built a touch event listener on each one that will hide one or the other. I do this in my games for my sound on/off buttons.
local soundOn = true
local soundOnBtn, soundOffBtn
local function soundToggle(event)
if soundOn then
soundOn = false
soundOnBtn.isVisible = false
soundOffBtn.isVisible = true
else
soundOn = true
soundOnBtn.isVisible = true
soundOffBtn.isVisible = false
end
return true
end
soundOnBtn = display.newImageRect("images/switch_on.png", 46, 36)
soundOnBtn.x = display.contentWidth / 2 + 25
soundOnBtn.y = display.contentHeight / 2 - 15
group:insert(soundOnBtn)
soundOnBtn:addEventListener("tap", soundToggle)
soundOffBtn = display.newImageRect("images/switch_off.png", 46, 36)
soundOffBtn.x = display.contentWidth / 2 + 25
soundOffBtn.y = display.contentHeight / 2 - 15
group:insert(soundOffBtn)
soundOffBtn:addEventListener("tap", soundToggle)
soundOffBtn.isVisible = false

Resources