473,386 Members | 1,886 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Recalculate Calculated Control on Form

Hi,

(Access 97)

On my Menu form I have a button (cmdRefreshLinks) that
refreshes/changes the linked tables in my database, and a calculated
control (txtDataSource) that uses a custom function to display the
location of the back-end database. (This is all done using Dev
Ashish's 'Relink Tables' code from
http://www.mvps.org/access/tables/tbl0009.htm.)

Both of these controls do exactly what they're supposed to, with one
exception. After I've refreshed the table links using
cmdRefreshLinks, txtDataSource doesn't update correctly. I've tried
virtually all combinations of the below lines of code in the Click
event of cmdRefreshLinks after it's carried out its refresh function:

--------
CurrentDb.TableDefs.Refresh
DoEvents
Me.Recalc
or Me.txtDataSource.Requery
or Me.Requery
or Me.Refresh
or Me.txtDataSource.Recalc (doesn't compile)
--------

When I use Me.txtDataSource.Requery, I SEE txtDataSource requery, but
it returns the incorrect (i.e. old) path. This is why I tried
DoEvents - I thought it might have needed a second to catch up with
itself.

I've now resorted to closing and reopening the form at the end of the
cmdRefreshLinks Click event, but surely there must be a better way?!

Thanks,
Linda Patterson
Nov 13 '05 #1
2 3544
Hi Linda,

This custom function of yours... does it parse the data path from one of the
linked table's .Connect string?
If not then I think that a new function that does just that is what you
need.

In fact, isn't that what the "fParsePath" function inside of Dev's code
does???
Take the name of one of the tables that you've just re-linked, and
debug.print it's .Connect String

eg.
******************* In the Debug window *****************
?CurrentDB.TableDefs("tblPartsInventory").Connect
returns:
;DATABASE=C:\Documents and Settings\Don\My Documents\Mck2004_be.mdb

Then use the fParsePath() function to parse out the data path.
?fParsePath(";DATABASE=C:\Documents and Settings\Don\My
Documents\Mck2004_be.mdb")
returns:
C:\Documents and Settings\Don\My Documents\Mck2004_be.mdb

-- Or even just write it as a combination --
?fParsePath(CurrentDB.TableDefs("tblPartsInventory ").connect)
C:\Documents and Settings\Don\My Documents\Mck2004_be.mdb
************************************

As a control source for "txtDataSource" =
fParsePath(CurrentDB.TableDefs("YourLinkedTableNam eHere").connect)

--
HTH,
Don
=============================
E-Mail (if you must)
My*****@Telus.net

Disclaimer:
Professional PartsPerson
Amateur Database Programmer {:o)

I'm an Access97 user, so all posted code
samples are also Access97- based
unless otherwise noted.

Do Until SinksIn = True
File/Save, <slam fingers in desk drawer>
Loop

================================

"Linda" <li*************@hertshighways.org.uk> wrote in message
news:a6**************************@posting.google.c om...
Hi,

(Access 97)

On my Menu form I have a button (cmdRefreshLinks) that
refreshes/changes the linked tables in my database, and a calculated
control (txtDataSource) that uses a custom function to display the
location of the back-end database. (This is all done using Dev
Ashish's 'Relink Tables' code from
http://www.mvps.org/access/tables/tbl0009.htm.)

Both of these controls do exactly what they're supposed to, with one
exception. After I've refreshed the table links using
cmdRefreshLinks, txtDataSource doesn't update correctly. I've tried
virtually all combinations of the below lines of code in the Click
event of cmdRefreshLinks after it's carried out its refresh function:

--------
CurrentDb.TableDefs.Refresh
DoEvents
Me.Recalc
or Me.txtDataSource.Requery
or Me.Requery
or Me.Refresh
or Me.txtDataSource.Recalc (doesn't compile)
--------

When I use Me.txtDataSource.Requery, I SEE txtDataSource requery, but
it returns the incorrect (i.e. old) path. This is why I tried
DoEvents - I thought it might have needed a second to catch up with
itself.

I've now resorted to closing and reopening the form at the end of the
cmdRefreshLinks Click event, but surely there must be a better way?!

Thanks,
Linda Patterson

Nov 13 '05 #2
Hi Don,

Well spotted - fParsePath is exactly what I'm using:

txtDataSource: =fParsePath([CurrentDb].[TableDefs]("prj_Projects").[Connect])

And it works fine every time except when I've just refreshed the table
links. I'd understand if it needed the TableDefs refreshed AND a
txtDataSource.Requery, but I've tried them and it still doesn't return
the new path.

I'll investigate further and see what Debug.Print-ing the function
shows me, but surely after a CurrentDb.TableDefs.Refresh it should be
correct?

Yours frustratedly,
Linda
"Don Leverton" <le****************@telusplanet.net> wrote in message news:<YRURc.74935$T_6.71711@edtnps89>...
Hi Linda,

This custom function of yours... does it parse the data path from one of the
linked table's .Connect string?
If not then I think that a new function that does just that is what you
need.

In fact, isn't that what the "fParsePath" function inside of Dev's code
does???
Take the name of one of the tables that you've just re-linked, and
debug.print it's .Connect String

eg.
******************* In the Debug window *****************
?CurrentDB.TableDefs("tblPartsInventory").Connect
returns:
;DATABASE=C:\Documents and Settings\Don\My Documents\Mck2004_be.mdb

Then use the fParsePath() function to parse out the data path.
?fParsePath(";DATABASE=C:\Documents and Settings\Don\My
Documents\Mck2004_be.mdb")
returns:
C:\Documents and Settings\Don\My Documents\Mck2004_be.mdb

-- Or even just write it as a combination --
?fParsePath(CurrentDB.TableDefs("tblPartsInventory ").connect)
C:\Documents and Settings\Don\My Documents\Mck2004_be.mdb
************************************

As a control source for "txtDataSource" =
fParsePath(CurrentDB.TableDefs("YourLinkedTableNam eHere").connect)

--
HTH,
Don
=============================
E-Mail (if you must)
My*****@Telus.net

Disclaimer:
Professional PartsPerson
Amateur Database Programmer {:o)

I'm an Access97 user, so all posted code
samples are also Access97- based
unless otherwise noted.

Do Until SinksIn = True
File/Save, <slam fingers in desk drawer>
Loop

================================

"Linda" <li*************@hertshighways.org.uk> wrote in message
news:a6**************************@posting.google.c om...
Hi,

(Access 97)

On my Menu form I have a button (cmdRefreshLinks) that
refreshes/changes the linked tables in my database, and a calculated
control (txtDataSource) that uses a custom function to display the
location of the back-end database. (This is all done using Dev
Ashish's 'Relink Tables' code from
http://www.mvps.org/access/tables/tbl0009.htm.)

Both of these controls do exactly what they're supposed to, with one
exception. After I've refreshed the table links using
cmdRefreshLinks, txtDataSource doesn't update correctly. I've tried
virtually all combinations of the below lines of code in the Click
event of cmdRefreshLinks after it's carried out its refresh function:

--------
CurrentDb.TableDefs.Refresh
DoEvents
Me.Recalc
or Me.txtDataSource.Requery
or Me.Requery
or Me.Refresh
or Me.txtDataSource.Recalc (doesn't compile)
--------

When I use Me.txtDataSource.Requery, I SEE txtDataSource requery, but
it returns the incorrect (i.e. old) path. This is why I tried
DoEvents - I thought it might have needed a second to catch up with
itself.

I've now resorted to closing and reopening the form at the end of the
cmdRefreshLinks Click event, but surely there must be a better way?!

Thanks,
Linda Patterson

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Anonymous | last post by:
Hi all, I have a form people use to enter checking data. One of the fields is calculated based on finding the difference of two input fields on the form. Here are the fields: CheckAmount...
3
by: Jeremy Weiss | last post by:
I've got a temp table that contains the fields: amountowed, amountpaid, and balanced. I've got a form that shows this information and I've set it up so that when the amountpaid field is changed it...
2
by: Tony Williams | last post by:
I have a form with a tabcontrol which has a number of pages. I want to check the value of a calculated control on one page with a calculated control on another page. The calculated control...
30
by: Shannan Casteel via AccessMonster.com | last post by:
I have a subform named "sbfrmParts" with a list of parts along with the quantity and price. I have used a text box in the subform's footer and set the control source to "=Sum(*)". I set the...
6
by: dhowell | last post by:
I have a "form" and "subform" where I would like a calculated control on the form which sums the values of a datasheet column of the subform. (datasheet on subform may have a variable number of...
15
by: Jimmy Stewart | last post by:
I want to use a calculated function for the caption on my tab controls. I used the following code: Me.Page28.Caption = "Expenses & "]" This should display the following: " Expenses " where...
3
by: kelley.l.turner | last post by:
Hi all, I am very new to MS Access so please bear with me! I have created a simple calculated field in my data entry form, yet when I view my data table or try to generate a report based on...
2
by: jcf378 | last post by:
hi all. I have a form which contains a calculated control ("days") that outputs the # of days between two dates (DateDiff command between the fields and ). However, when I click "Filter by...
9
by: Haas C | last post by:
Hi all! Is there anyway I can override a value in a calculated field on a form? For example: I have a form which displays the following fields based on a query: Premium Due field has the...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.