Hi Guys and Girls,
I have created a Database which we call a filechecker, its to check users are doing there job correctly.
Everything i have done on the databse is from the internet and a few videos so please be gentle with how its built
I would like some help with VBA, module or Macro with the following please:
Please see attached database.
Here are step i hope can help understand what i need help with:
1. On the HomePage_frm select the File Checker btn.
2. this will open the FileChecker_frm (There is some VBA code for this form upon loading to Name the btns as you can see(these names are from the Users_tbl Authority=Supervisors)
3. when you click one of the btns ( eg.Richard Bartlett) it will open the FileCheckSelection_frm, this form has hidden btns ( you can see these in design view).
4. what i want to do between the FileChecker_frm and the FileCheckSelection_frm is open the FileCheckSelection_frm but only display the btns that the user has a yes against in the Users_tbl.
5 Also when the FileCheckSelection_frm loads with there buttons they can access, when they click the btns of choice it will open the form for them (eg. BrokerFileCheck_frm)
6. when the eg.BrokerFileCheck_frm opens then it only open for the supervisor that was selected from the FileChecker_frm.
i hope it all makes sense and any help would greatly appreciated.
I tried the following code but im doing something wrong somewhere and i can see it.
Private Sub Form_Load()
Dim SQL As String
SQL = "Select * " & _
"FROM Users_tbl " & _
"WHERE 'Broker = -1 AND Executive = -1 AND Arborisk = -1 AND Claims = -1 AND Private_Client = -1 AND Client_Direct= -1'"
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset(SQL)
Dim strText As String
Dim myNum As Integer
myNum = 4
Do While Not rs.EOF
strText = rs.Fields("Broker")
strText1 = rs.Fields("Executive")
strText2 = rs.Fields("Arborisk")
strText3 = rs.Fields("Claims")
strText4 = rs.Fields("Private_Client")
strText5 = rs.Fields("Client Direct")
'Make Buttons here
'Set newButton = CreateControl(Me.Name, acCommandButton)
Dim buttonName As String
Dim actualButton As Control
buttonName = "Command" & myNum
UpdateButton buttonName, strText
myNum = myNum + 1
rs.MoveNext
Loop
End Sub
Public Function MyOpenForm(FormName As String)
DoCmd.OpenForm FormName
End Function
Private Sub UpdateButton(buttonName As String, strText As String)
Dim cCont As Control
For Each cCont In Me.Controls
If TypeName(cCont) = "CommandButton" Then
If cCont.Name = buttonName Then
'cCont.Name = "gbtn_" & strText
cCont.Visible = True
cCont.Enabled = True
cCont.Caption = strText
cCont.ControlTipText = strText
'cCont.OnClick = "=MyOpenForm(""BrokerFileCheck_frm"")"
'.Width = 100
'.Height = 30
'.Top = 12 + (curRow * 1584)
'.Left = 12 + (curCol * 1584)
'.BackThemeColorIndex = 1
'.HoverThemeColorIndex = 4 'Accent 1
'.HoverShade = 0
'.HoverTint = 40 '60% Lighter
'.PressedThemeColorIndex = 4 'Accent 1
'.PressedShade = 0
'.PressedTint = 20 '80% Lighter
End If
End If
Next cCont
End Sub
Thanks
Simon
End Sub
I have created a Database which we call a filechecker, its to check users are doing there job correctly.
Everything i have done on the databse is from the internet and a few videos so please be gentle with how its built
I would like some help with VBA, module or Macro with the following please:
Please see attached database.
Here are step i hope can help understand what i need help with:
1. On the HomePage_frm select the File Checker btn.
2. this will open the FileChecker_frm (There is some VBA code for this form upon loading to Name the btns as you can see(these names are from the Users_tbl Authority=Supervisors)
3. when you click one of the btns ( eg.Richard Bartlett) it will open the FileCheckSelection_frm, this form has hidden btns ( you can see these in design view).
4. what i want to do between the FileChecker_frm and the FileCheckSelection_frm is open the FileCheckSelection_frm but only display the btns that the user has a yes against in the Users_tbl.
5 Also when the FileCheckSelection_frm loads with there buttons they can access, when they click the btns of choice it will open the form for them (eg. BrokerFileCheck_frm)
6. when the eg.BrokerFileCheck_frm opens then it only open for the supervisor that was selected from the FileChecker_frm.
i hope it all makes sense and any help would greatly appreciated.
I tried the following code but im doing something wrong somewhere and i can see it.
Private Sub Form_Load()
Dim SQL As String
SQL = "Select * " & _
"FROM Users_tbl " & _
"WHERE 'Broker = -1 AND Executive = -1 AND Arborisk = -1 AND Claims = -1 AND Private_Client = -1 AND Client_Direct= -1'"
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset(SQL)
Dim strText As String
Dim myNum As Integer
myNum = 4
Do While Not rs.EOF
strText = rs.Fields("Broker")
strText1 = rs.Fields("Executive")
strText2 = rs.Fields("Arborisk")
strText3 = rs.Fields("Claims")
strText4 = rs.Fields("Private_Client")
strText5 = rs.Fields("Client Direct")
'Make Buttons here
'Set newButton = CreateControl(Me.Name, acCommandButton)
Dim buttonName As String
Dim actualButton As Control
buttonName = "Command" & myNum
UpdateButton buttonName, strText
myNum = myNum + 1
rs.MoveNext
Loop
End Sub
Public Function MyOpenForm(FormName As String)
DoCmd.OpenForm FormName
End Function
Private Sub UpdateButton(buttonName As String, strText As String)
Dim cCont As Control
For Each cCont In Me.Controls
If TypeName(cCont) = "CommandButton" Then
If cCont.Name = buttonName Then
'cCont.Name = "gbtn_" & strText
cCont.Visible = True
cCont.Enabled = True
cCont.Caption = strText
cCont.ControlTipText = strText
'cCont.OnClick = "=MyOpenForm(""BrokerFileCheck_frm"")"
'.Width = 100
'.Height = 30
'.Top = 12 + (curRow * 1584)
'.Left = 12 + (curCol * 1584)
'.BackThemeColorIndex = 1
'.HoverThemeColorIndex = 4 'Accent 1
'.HoverShade = 0
'.HoverTint = 40 '60% Lighter
'.PressedThemeColorIndex = 4 'Accent 1
'.PressedShade = 0
'.PressedTint = 20 '80% Lighter
End If
End If
Next cCont
End Sub
Thanks
Simon
End Sub