Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Welcome to the skill header Forums. You can ask questions, get help, or help other members out. Join our Forum for free.
Hello!
I am creating a database for our family business and this tutorial has already been life changing!
However, I am having an issue writing the code for the 'Main Dashboard> Event> On Load'
I am getting an error with 'rstPrf'
I can't find where this is supposed to refer to in order to check spelling etc. (I had this issue once already)
Please help! I am only on the first tutorial video but can't wait to finish the rest once this problem is resolved!
Thanks in advance,
Tamara
Because you are using "Options Explicit" like I do in all my VBA code. You need to DIM the record set before it will recognize it.
Try changing your code to:
Private Sub Form_Load()
Dim rstPrf As Recordset
Set rstPrf = CurrentDb.OpenRecordset("tbl_profile", dbOpenDynaset, dbSeeChanges)
With rstPrf
.FindFirst "prfID=" & aprofile
If .Fields("prfDashboard") = 0 Then Me.NavigationButton11.Enabled = False
If .Fields("prfAnalysis") = 0 Then Me.NavigationButton13.Enabled = False
If .Fields("prfSales") = 0 Then Me.NavigationButton15.Enabled = False
If .Fields("prfPurchase") = 0 Then Me.NavigationButton17.Enabled = False
If .Fields("prfProducts") = 0 Then Me.NavigationButton19.Enabled = False
If .Fields("prfStock") = 0 Then Me.NavigationButton21.Enabled = False
If .Fields("prfEmployees") = 0 Then Me.NavigationButton23.Enabled = False
If .Fields("prfAccounts") = 0 Then Me.NavigationButton25.Enabled = False
If .Fields("prfPreferences") = 0 Then Me.NavigationButton27.Enabled = False
End With
Set rstPrf = Nothing
Keep the Public Variable declaration separate from the Main Dashboard Form in a Module with "Option Explicit" and keep the rest of the code from the On Click Event of the Main Dashboard Form without "Option Explicit".
While Ursh is the real expert here and with every ounce of respect I have for him, I have to disagree. While this appears to be a personal preference issue, there are some good arguments for both sides. The two best articles I could find for you in order to view both perspectives can be found at:
Reliable Excel VBA Code: Best Practices - Master Office VBA
Again, this is my preference that I have based on experience. So, when I am responding I do come from that viewpoint. Happy Coding everyone!