Button to create form for certain member ?

oMADMANo

Registered User.
Local time
Today, 13:33
Joined
Jan 19, 2012
Messages
11
Hi im fairly new to all this codeing in access but i think this is possible.
I have put together a simple database for my members for me to view all there information but i would like to be able to have a 2nd form open only for some members with a button that would have more option boxes.
so basicaly i can code the button to open a general form but i want this 2nd form to be linked and named to that member.
example:
Button > 'Enter risks for this member' would open a form for this member(already designed) with the Title 'Risk for member 1' and then display a page linked to that member.
Could any one briefly explain the button i would need and also how i code the header title to display the members name.
Thanks.
 
If the first form is still open, you can pull values from it into the second form.

Code:
Me.MemberName.Value = FirstFormName.MemberName.Value
 
Thanks that helps for the title. Just stuck on the button now.
Im thinking something like:
Private Sub RiskButton_Click()


DoCmd.OpenForm
"Risk(Me.MemberName.Value = FirstFormName.MemberName.Value)"

End Sub

Wich would create a risk form for that member as i dnt need risk forms for every member.

p.s 'Risk' is the template name for the form im trying to link to the member.
 
one way is to test the usename (windows logged in name)

Code:
select case environ ("username")
    case ("Administrator","Mike"): 'do nothing
    case else: 
             msgbox("sorry you cannot do this action")
            exit sub
end select

The only trouble with stuff like this, is that you have to edit the code every time you want to change the authorised users - so what more complex apps would do, is store the privileges/authorised users in a table - then you can edit the table without needing to change the code.

-but then you may decide you need to limit who can open the table to manage the authorisations. Which is all part of why passwords become so very important.
 
Im sorry i didnt mean it like that , i just meant if any one could provide some additional information on this as i am still a bit stuck.
Thanks
 
So let's get some facts straight.

1. You have a form that displays all members
2. You want to create a button so that when clicked, it will open the current member with full details about this member?
 
I do have a first form with all members details but i want the 2nd form only to have the members name as title and then have more options which are from the template I made.
 
Sorry for edit
i used This instead
Code:
Private Sub RiskButton_Click()

Dim rs As Object
Dim RiskBookmark As Long

'set a variable to the current record
RiskBookmark = Me.txtMemberID
'open the new form
DoCmd.OpenForm "Risks"

'take it to the selected record
Set rs = Forms!Risks.RecordsetClone
rs.FindFirst "MemberID = " & RiskBookmark

'the lines marked as optional can be included if there's a chance the record won't exist in the form being opened
If rs.NoMatch Then   'optional - if no match, go to a new record
  DoCmd.GoToRecord acForm, "Risks", acNewRec   'optional
  Forms!Risks.txtMemberID = Me.txtMemberID  'optional - copy the Member ID from this form
Else   'optional
  Forms!Risks.Bookmark = rs.Bookmark
End If   'optional
Set rs = Nothing


End Sub

But I don't get this bit 'Me.txtMemberID'
I haven't set member Ids or I don't think I have. I do have record numbers could I possibly change it to this ?
 
Last edited:
You want me to advise you on a different method than the one I recommended?
 
If you wouldn't mind then yes maybe I cant seem to get that code to work because like I said I don't have the me.MemberId set up just a number for the record.
Thanks
 
Wellm oMADMANo, the code I gave you will do what you want in just one line and it will be much quicker than the code you found. Also, trying to implement code without understanding what it does in its entirety won't be of much help to you because the end result may not be what you intended.

From what you described, the code I gave you will do it. The code you have above will NOT filter the form, it will only move to the record.

So you need to be explicit and tell us exactly what you want it to do?

1. Open the form
2. Filter the form based on the MemberID

OR

1. Open the form
2. Find the MemberID and move to that record
3. But still show other members if you click Next or Previous record
 
1. Open the form
2. Find the MemberID and move to that record
3. But still show other members if you click Next or Previous record
could work.
 
And you want it to move to a new record IF there's no matching member with that ID?
 
Solved.
I made the form "Risks" a child form and then used
Code:
Private Sub RiskButton_Click()

Dim cr As Integer
cr = CurrentRecord
DoCmd.OpenForm "MembershipChildRisk"
DoCmd.GoToRecord acActiveDataObject, frmPatents, acGoTo, cr

End Sub
 

Users who are viewing this thread

Back
Top Bottom