Solved

Update a form, based on a selection from another form

Posted on 2011-09-09
7
275 Views
Last Modified: 2012-05-12
I have setup two networked PCs with MSAccess 2003.
I want the first pc to put entries into a table using a form, then what ever entry is currently selected on the 1st PC's form called form1, I want the 2nd pc to display that record on the 2nd PCs form2.
to amplify.
I have a table with only 4 entries.
On form 1 on pc 1 i have selected entry 3.
I want pc 2 using form2 to display the entry 3.
Then if i change the entry on PC1 form1 to entry 2
I want pc 2 to reflect entry 2
Can u advise?
0
Comment
Question by:jwjjwj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 36514856
I hope you are good at VBA...
Note that while this works, things like this (running commands across databases) is *extremely* risky and unpredictable.
You will also have to customize this code to work just the way you need it to.

But again, it works OK in both PC are *Tightly controlled*, otherwise all sorts of odd things can start happening...
(You should have iron-clad error handling on all subs and perhaps implement "RollBack" code)
This is why I stated that you should be well versed in VBA before attempting this...


In any event...
Put this in the code for the Form in the 1st PC:

Private acc As Access.Application

Private Sub Form_Open(Cancel As Integer)
Set acc = New Access.Application
    acc.OpenCurrentDatabase "c:\YourFolder\TargetDB.mdb"
    acc.Visible = True
    acc.DoCmd.OpenForm "frmCustomers"
End Sub

Private Sub Form_Current()
Dim strCustID As String
strCustID = Me.CustomerID
    acc.DoCmd.OpenForm "frmCustomers", , , "CustomerID=" & "'" & Me.CustomerID & "'"
End Sub


Private Sub Form_Close()
    acc.CloseCurrentDatabase
    Set acc = Nothing
End Sub



Make sure the second db has the exact same form name and table available.

;-)

JeffCoachman
0
 

Author Comment

by:jwjjwj
ID: 36516035
Hi Jeff, thanks for that, however I have not explained myself clearly enough.
There is only one db, with one table and two forms. one and entry form on the 1st pc and the other a display form on a 2nd pc, both from the same db.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 36516468
Is the one DB "Split"?
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

Author Comment

by:jwjjwj
ID: 36517876
No, the db is not split. it is just a stock standard database, networked between two pc's.
One pc has and update form, the other a display of the latest data which has been seletect on the update form
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 500 total points
ID: 36526635
Try this

(It is not clear how you are handling the opening and closing of these forms, but this should work...)

Have two forms with the same recordsource.
On Form1 (The"Control" form) put code like this on the current event:

Forms![Form2].Filter = "ID=" & me.ID
Forms![Form2].FilterOn = True

I am sure you can easily modify this to work in your database.
0
 

Author Closing Comment

by:jwjjwj
ID: 36527402
Thank u - works like a dream.
May require further help as I now have to kick off a list that I want to display, but if so, I will ask another question.
Regards
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 36529623
;-)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
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…

749 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