Solved

Update a form, based on a selection from another form

Posted on 2011-09-09
7
272 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
  • 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
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
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…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

707 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

19 Experts available now in Live!

Get 1:1 Help Now