Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading table properties

Status
Not open for further replies.

Tazcat

Technical User
Feb 17, 2003
40
US
I'm trying to write a form-load function, which will read the property of a table in my db, and display on the form the date the table in question was last updated (sort of a systems check to be sure things are working correctly.) I have this piece of code, which my brain suggests should work properly, but of course this is Access, so it doesn't. Would appreciate any feedback I could get on this one. Thanks!!

Private Sub Form_Load()
Dim dbsRefmd As Database
Dim tdfDICT123 As TableDef

Set dbsRefmd = OpenDatabase("Refmd.mdb")
Set tdfDICT123 = dbsRefmd.TableDefs!DICT123

Form_MainMenu.Updated.Caption = "Last Updated: " & tdfTemp.LastUpdated

End Sub

 
Hi Tazcat,

Sure this will work but you have to reference the tabledef that you have created instead of this:

Form_MainMenu.Updated.Caption = "Last Updated: " & tdfTemp.LastUpdated

Do this:
Form_MainMenu.Updated.Caption = "Last Updated: " & tdfDICT123.LastUpdated

Let me know if this helps.



Regards,
gkprogrammer
 
Right, I AM a moron. At any rate, I did fix that line of code, and it still doesn't work. Code is now:
Private Sub Form_Load()
Dim dbsRefmd As Database
Dim tdfDICT123 As TableDef

Set dbsRefmd = OpenDatabase("Refmd.mdb")
Set tdfDICT123 = dbsRefmd.TableDefs!DICT123

Form_MainMenu.Updated.Caption = "Last Updated: " & tdfDICT123.LastUpdated

End Sub

Any thoughts?
 
What isn't working, are you receiving an error message if so what is it?

Regards,
gkprogrammer
 
on compile: Compile error: user defined type not defined:
Dim dbsRefmd As Database


I thought this was a standard class?
 
In your References make sure you have the Microsoft DAO 3.6 Object Library (you may have a different version than 3.6, use the version you have)selected.

Regards,
gkprogrammer
 
Another suggestion. Presuming the name of your text box is "Updated" and the name of the form is "Form_MainMenu", try this:

Forms.Form_MainMenu.Updated = "Last Updated: " & tdfDICT123.LastUpdated
 
Did that, compile error is gone, but it still displays nothing but the text "Last Updated: ". Doesn't seem to be capturing the update date from the table. Can you think of any other way I might write this function? Can't thank you enough for helping with this.
 
I'm using a lable, rather than a text box. I did try your suggestion, but with no luck.
 
Hmmm. I'm looking at a version of your code that works perfectly. The only difference I can see is that mine specifies the whole path for the target database. For example:

Set dbsRefmd = OpenDatabase("c:\Development\Refmd.mdb")

I don't think this should cause your text box to be blank though. Are you certain your text box is named "Updated" and your form is named "Form_MainMenu"?
 
Just to make sure that this property is not the culprit try testing it using the MsgBox function, I quickly tried this and it worked as expected for me:

Dim dbs As Database
Dim tdf As TableDef

Set dbs = CurrentDb
Set tdf = dbs.TableDefs!DICT123

MsgBox "Last Updated: " & tdf.LastUpdated
dbs.Close

Let me know how it goes.

Regards,
gkprogrammer
 
dbelsey, bless you. Since you said that about the path, I tried passing it the current project path, and IT WORKED.
 
GKProgrammer, my deep thanks to you as well, for fixing the DAO problem.
 
Fantastic! (But I HATE being wrong about that not causing the problem. Grrr...) :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top