?
Solved

Edit button to load form using selected record

Posted on 2007-07-24
9
Medium Priority
?
278 Views
Last Modified: 2013-11-28
Hello Experts,

I'm working on an MS 200 db, and I have an advanced search which feeds into a display form.
I want to add an edit button next to each record, which captures it's p_key and loads an edit person form for exactly the record the user selected the edit for. How do i go about doing that? Please may you post some demo code for me or forward me to some tutorial i may get a clue from? Any help would be highly appreciated!

Thanks :)
Nadia
0
Comment
Question by:NadiaRashid
  • 5
  • 4
9 Comments
 
LVL 61

Expert Comment

by:mbizup
ID: 19559254
The code would look like this:

Docmd.OpenForm "MyEditForm",,,"[pkfield] = " & me.P_key
0
 

Author Comment

by:NadiaRashid
ID: 19567507
Hi mbizup,

I tried this code in my edit button :

Private Sub btnEdit_Click()
DoCmd.OpenForm "MyForm", , , "[pkey.Table.] = " & Me.pkey
End Sub

But when i run it in my form it does nothing. Any suggestions?? By the way thank for your response! :)
0
 
LVL 61

Expert Comment

by:mbizup
ID: 19567633
Just nothing... no form opening, no errors?

Double check that you are using the correct names for your application:

DoCmd.OpenForm "MyForm", , , "[pkey.Table.] = " & Me.pkey
                                ^--- The form to be opened              ^--- The control or field containing the ID

Then make sure that the code is "tied" to the event:
- In your command button's property sheet, click the "..." next to On click under the Events tab.  This should bring up the code you typed in.  If the code was not tied to the event previously, it should be now.

If this does not help, can you post a sample of your db at www.ee-stuff.com ?   Use youe EE username and password.  The upload should be a zipped file, no more than 4 meg.  Post the URL that ee-stuff provides you in your next comment here.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:NadiaRashid
ID: 19568588
The code is tied to the event, I performed the check you advised. I made a couple of edits in the form, so now it give me the following error:

Invalid bracketing of name "[pkey.Table]"

and here is my code:

Private Sub btnEdit_Click()
On Error GoTo Err_btnEdit_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "Table"
    DoCmd.OpenForm stDocName, , , "[pkey.Table] = " & Me.pkey
   
Exit_btnEdit_Click:
    Exit Sub

Err_btnEdit_Click:
    MsgBox Err.Description
    Resume Exit_btnEdit_Click

End Sub

0
 
LVL 61

Expert Comment

by:mbizup
ID: 19568616
What is the exact name of the field you are working with?  Let me know, in this format:

Table Name:  ?
Field Name:  ?
0
 

Author Comment

by:NadiaRashid
ID: 19568629
Table Name = PatientTable
FeildName = PatientID
0
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 19568649
Try this:

DoCmd.OpenForm stDocName, , , "PatientID = " & Me.pkey
                                                                                       ^--- Make sure this is the name of the field/control onyour form.
0
 

Author Comment

by:NadiaRashid
ID: 19568700
YESS! it works! thanks so much :)
0
 
LVL 61

Expert Comment

by:mbizup
ID: 19568708
Glad to help :-)
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Suggested Courses

850 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