Solved

Changing tag property

Posted on 2004-07-30
14
287 Views
Last Modified: 2008-02-20
how can i change the tag property at a click of a button? im password protecting the form thru the tag property..now ive setup another form to change the passwrod(tag)..my code in that other form is:

On Error GoTo Err_Command9_Click
   
        Dim stDocName As String
        Dim stLinkCriteria As String

        stDocName = "frmAdmin"
        DoCmd.OpenForm stDocName, , , stLinkCriteria
       
        [Forms]![frmadmin].Tag = txtNewPass

after i click the button, i dont get any error msg and the tag property doesnt change either..whats going wrong?
0
Comment
Question by:thinker388
  • 4
  • 3
  • 3
  • +4
14 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 11678530
did u try changing the tag property before u open the form?
0
 
LVL 6

Assisted Solution

by:knollbert
knollbert earned 100 total points
ID: 11678562
Try

        Dim stDocName As String
        Dim stLinkCriteria As String

        stDocName = "frmAdmin"
        DoCmd.OpenForm stDocName, , , stLinkCriteria
       
        [Forms]![frmadmin].form.Tag = txtNewPass
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 11678568
na, u cant unless u first open it in design mode

the alternative is to create a public procedure in that form, then call that passing in the password, and called code does the rest or have a hidden textbox
0
 

Author Comment

by:thinker388
ID: 11678570
i did this:

If txtNewPass = txtCNewPass Then
[Forms]![frmadmin].Tag = txtNewPass
    On Error GoTo Err_Command9_Click
   
        Dim stDocName As String
        Dim stLinkCriteria As String

        stDocName = "frmAdmin"
        DoCmd.OpenForm stDocName, , , stLinkCriteria

still doesnt work
0
 
LVL 6

Expert Comment

by:knollbert
ID: 11678571
It worked for me
0
 
LVL 6

Expert Comment

by:knollbert
ID: 11678575
Note
[Forms]![frmadmin].form.Tag = txtNewPass
 NOT
[Forms]![frmadmin].Tag = txtNewPass
0
 
LVL 17

Assisted Solution

by:walterecook
walterecook earned 100 total points
ID: 11678577
Put a break on [Forms]![frmadmin].Tag = txtNewPass
Are you sure txtNewpass has a value at that time?

Walt
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 5

Expert Comment

by:Jag5x5
ID: 11678585
Dont think you can at run time permenatly change the tag property of a form that is what you are trying to do yes?

I would create a hidden table and store the password in that.  I usually use a table called tblpref and store the password in that.  I use 2 field key and string I set the key to password and the string to the password.  then I do a dlookup to test if the password is correct and use an rs or a query to change it.

HTH

Jag5x5
0
 

Author Comment

by:thinker388
ID: 11678603
knollbert...that didnt work...

rockiroads...can u expand a bit upon the alternative?


create a public procedure in which form? the one with the txtnewpass or the one whose tag property i wanna change..

and where should i call it? and should it have the exact code as in my existing clicck procedure?

and how can i use the hidden textbox?

Thanks...
0
 

Author Comment

by:thinker388
ID: 11678644
knoll...ive tried both ways..no luck

walter..im sure...cuz i have two fields..passwd and conf passwd..n i only let the procedure run if they r equal...ive tried typing in diff values for the two passwd boxes..and it didnt run as planned...


jag..yes thats what im trying to do
0
 
LVL 65

Accepted Solution

by:
rockiroads earned 100 total points
ID: 11678679
your original code should work

        DoCmd.OpenForm stDocName, , , stLinkCriteria
        [Forms]![frmadmin].Tag = txtNewPass

and so should's knolbert

do as he suggests

        msgbox "Setting tag to " & txtNewPass
        [Forms]![frmadmin].Tag = txtNewPass

to see what your setting

my idea was something like this

Public Sub SetTag(ByVal sVal As String)
    Me.Tag = sVal
End Sub

then call it like this

        [Forms]![frmadmin].SetTag txtNewPass


but a better idea might be to use the arguments

the last paramater for DoCmd.OpenForm is arguments, if u passed in txtNewPass

then on Form_Load, use OpenArgs

private sub Form_Load()
    Me.Tag = OpenArgs
end sub




0
 
LVL 32

Assisted Solution

by:jadedata
jadedata earned 100 total points
ID: 11684672
The form MUST be opened in acDesignView in order to make the change "stick" to the property.  
Opening in any form view, hidden or not will only change the property while it is open on that occurance.  The property reverts to its default on losing the form.

I would suggest that you use a settings table to drive this process instead of a form property anyway.  You risk locking yourself out of design views if the key property gets set incorrectly.
0
 
LVL 44

Assisted Solution

by:GRayL
GRayL earned 100 total points
ID: 11685175
I just checked and you can permanently change the tag value of a form at runtime. However to keep the new value of the tag issue:
docmd.close "formName", acSaveYes
0
 

Author Comment

by:thinker388
ID: 11704507
ok i just talked with the person  for whom I'm doing this project for, and he said that he's just going to change the tag by going to design view himself. :)

Thanks a lot for the replies...I'll split up the points.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now