Is Public Variable declaration way any semiliar in Access to?

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
Hi, I tried tried it like this and seems to work, but dont want to get into any problem latter...so please confirm if 'm declaring this in the right way....


Thanks alot!
Code:
[/FONT]
[FONT=Courier New]Option Compare Database
Dim AccessX As Boolean
Public Function VarialbeX()
Dim mycri As String
mycri = 1[/FONT]
[FONT=Courier New]
If mycri = 2 Then
AccessX = True
Else
AccessX = False
End If
End Function
Sub TestmyFunction()
MsgBox AccessX
End Sub
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
If you want to use the variable in all modules use:

Public AccessX As Boolean

and normally to use within the specific module you use

Private AccessX As Boolean


The word DIM should only really be used INSIDE a procedure.
 
Upvote 0
If you want to use the variable in all modules use:

Public AccessX As Boolean

and normally to use within the specific module you use

Private AccessX As Boolean


The word DIM should only really be used INSIDE a procedure.



Bob, thanks for quick reply...
Actually i want to triger this code when the database is opened and want to be able to use this variabe from anycodes within the databse untill the database it closed.

I want to loop thought the table and if usename is found then set accessx to true and permit the users to specefic forms etc..

'm i getting this right and how do i make this function to triger when database startup form is trigered...?
 
Upvote 0

Forum statistics

Threads
1,224,606
Messages
6,179,866
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top