Hi,
I found some material about this topic but it all refered to vb6.
I have a table which contains names of the forms in my system. After getting the form name out of the table, i want to set the "AllowEdits" property of that form to false, but for that i need to convert the string which contains the form name into a Form object, at least so i think.. here is a piece of my code: -
Do While Not rs.EOF
-
Select Case rs("formNum")
-
Case 1:
-
rsForms.FindFirst ("formNum = ") & rs("formNum")
-
If rsForms.NoMatch = False Then
-
strFormName = rsForms("formEnglishName")
-
strFormName.AllowEdits = False
-
....
-
strFormName holds the form name, but what should i do in order for the last line (in bold) to work?
Thanks in advance
10 10137
Are you delcaring strFormName as a form type, not a string?
Like: @Megalog
Hi Megalog,
I actually declared it as string. That way i can assign it the form name, but can't assign form property (such as AllowEdits). And if i declare it as Form, than i can assign the property but don't have the name..
NeoPa 32,556
Expert Mod 16PB
There are collections available that allow you to pass a string parameter to select the matching item. - {Application.}Forms All currently open forms.
-
CurrentProject.AllForms All forms in the project.
Forms("YourFormName") returns that form as long as it's already open and available. The {Application.} part is optional.
This can go in after line 5 from your initial posting: - DoCmd.OpenForm rsForms!formEnglishName, acDesign
-
If Forms(rsForms!formEnglishName).AllowEdits = True Then
-
Forms(rsForms!formEnglishName).AllowEdits = False
-
End If
-
DoCmd.Close acForm, rsForms!formEnglishName, acSaveYes
Just out of curiosity what are you using this for?
Wow, it works! Thank you Megalog!:) I just added acHidden to window mode, so it won't pop.
TheSmileyOne, i'm trying to implement restrictions for users. I created a form with a listbox filled with form names, so that whoever sets the configurations will choose set of forms for each worker, which he will not be allowed to modify. It's all my creation, so i'm sure it's not the most clever way, and i'm sure it will be modified not once, but at least what i have now works, thanks again.
Now i'm thinking about a way to add an option to choose exactly what restriciton will be implemented for each form, something like checkboxes for edits/additions/deletions.
Is there a way to remember listbox selection?
The process is: I choose some values (form names) in the listbox, press button "save choice", then my code activates and the values go in the table as supposed to, but the next time i enter the form the listbox is fresh, and i want it to be exactly as it was when i left it (the chosen lines must be black). I thought maybe on form Load event go through the table which holds the chosen values, and make them appear as chosen, but how?
This is some code I wrote myself, to convert the stored values into a comma delimite list, and store it in a hidden textbox, bound to a hidden TEXT field. (of course this only works if the length of the string wont exceed 255)
I only use this in a search form, to remember the users last performed search, so its not critical. If its something you need to store what user can access, I might want to write the data to tables instead of a string.
Anyways, here it is, and im sure you can modify it to read/restore the data of the table. To STORE the values - Private Sub list_Status_BeforeUpdate(Cancel As Integer)
-
-
StoreList Me.list_Status, Me.tb_status
-
-
End Sub
To RESTORE the values - Private Sub Form_Current()
-
'Restore the list selections
-
restoreList Me.list_Status, Me.tb_status
-
restoreList Me.list_Grade, Me.tb_Severity
-
-
End Sub
The procedures used: - Public Sub StoreList(ctrlListBox As Control, ctrlTextBox As Control)
-
'Lets store the items selected in the listbox
-
'Check that ctrlListBox is truly a listbox
-
If ctrlListBox.ControlType <> acListBox Then
-
MsgBox "This is not a listbox!"
-
Exit Sub
-
End If
-
-
'Check that ctrlTextbox is truly a textbox
-
If ctrlTextBox.ControlType <> acTextBox Then
-
MsgBox "This is not a textbox!"
-
Exit Sub
-
End If
-
-
'Dim variables
-
Dim lvItem As Variant
-
Dim intI As Integer
-
Dim strStorage As String
-
-
'Loop through selected items
-
For Each lvItem In ctrlListBox.ItemsSelected
-
strStorage = strStorage & "," & ctrlListBox.ItemData(lvItem)
-
Next
-
-
'If no items are selected then
-
If strStorage & "" <> "" Then
-
ctrlTextBox = Right(strStorage, Len(strStorage) - 1)
-
Else
-
ctrlTextBox = Null
-
End If
-
-
-
Set lvItem = Nothing
-
-
End Sub
- Public Sub restoreList(ctrlListBox As Control, ctrlTextBox As Control)
-
'Load the listbox
-
On Error GoTo exitSub
-
-
'Init variables
-
Dim intI As Integer
-
Dim intCount As Integer
-
Dim myVar As Variant
-
'Unmark all
-
DoCmd.Echo (False) 'Turn of painting
-
For intI = 0 To ctrlListBox.ListCount
-
ctrlListBox.Selected(intI) = False
-
Next
-
-
'If nothing is selected, go ahead and end sub
-
If ctrlTextBox & "" = "" Then GoTo endSub
-
-
'How many items are marked as selected
-
intCount = CharCount(ctrlTextBox, ",")
-
-
Dim intJ As Integer
-
'Restore teh selections
-
For intI = 0 To intCount
-
myVar = CVar(Split(ctrlTextBox, ",")(intI))
-
For intJ = 0 To ctrlListBox.ListCount
-
If ctrlListBox.ItemData(intJ) = myVar Then
-
ctrlListBox.Selected(intJ) = True
-
End If
-
-
Next
-
Next
-
-
endSub:
-
DoCmd.Echo (True)
-
-
Exit Sub
-
exitSub:
-
Debug.Print Err.Number & " - " & Err.Description
-
DoCmd.Echo (True)
-
-
End Sub
If you're using A2007, you can create a multivalue field in the table, and bind the listbox to it. Then it'll remember all the selections you make. Quite quick to set up, but the downside is that using MV fields is a real pain if you need to extract values out of there for use elsewhere.
TheSmileyOne, thanks a lot for the code. My values are stored it a table anyway, but i did use the ".Selected" property, it does paint the line as chosen, for some reason i didn't find it earlier ... now i have another problem, but i'll try to figure it out.
Megalog, i'm using Access 2003
Sign in to post your reply or Sign up for a free account.
Similar topics
by: JimMenees |
last post by:
I know there's an easy answer to this which is escaping me:
--------------------------------------------------------------------------
-----------------------
I have clickable thumb images which...
|
by: Altramagnus |
last post by:
I have a complicated Region object, which I need to draw the outline, but
not fill
How can I convert the Region object to GraphicsPath object?
or How can I draw the outline of the Region object?
|
by: Nathan |
last post by:
Is there a way to convert a string to a CipherMessage? I am calling a
function that decrypts a CipherMessage and returns the value. The only
problem is when I want to use an encrypted value stored...
|
by: xendrax |
last post by:
I was told on this site eval was bad but its the only way i can work out how to do it.. their example was
use var imdesc = document.myform.value
not var imdesc = eval("document.myform." +...
|
by: XML newbie: Urgent pls help! |
last post by:
function to convert string to 1 dimensional array of long in VB.Net
|
by: Ursula |
last post by:
Is it possible to convert a string in a file. The problem is this:
I have an object string that is a file xml and I want to pass to Deserialize
function, but Deserialize function expect an object...
|
by: amit75 |
last post by:
hi every body. Presently I am using vb.net. Now i am facing a problem that how to convert a string value to vb.net form object
|
by: Blackmore |
last post by:
I am trying to use javascript to calculate the difference between two form inputted dates and return the result to another form object. When I load up the page with the function on my web browser...
|
by: devonknows |
last post by:
Hi, The problem im having is, Im creating a user control. The user (via the Property Page's) will set his own menu titles, and the choose a form of which that title links to. If that makes sense.
...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |