Hi,
I have users that "should have" installed an update to their database tables. I need to be sure they have done this prior to giving them a new update. I would like to be able to use the onload function to see if the table has the new field. In this instance it would be tblReceipts and the field is [privateuse]. What would the code look like for something like this?
Thanks!
Leesha
Checking to look if field is in a table
-
- BronzeLounger
- Posts: 1488
- Joined: 05 Feb 2010, 22:25
-
- Administrator
- Posts: 78582
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Checking to look if field is in a table
Here is a general function to check if a field is missing:
Use like this:
Code: Select all
Function MissingField(TableName As String, FieldName As String) As Boolean
Dim dbs As DAO.Database
Dim tdf As DAO.TableDef
Dim fld As DAO.Field
Set dbs = CurrentDb
On Error Resume Next
Set tdf = dbs.TableDefs(TableName)
Set fld = tdf.Fields(FieldName)
If fld Is Nothing Then
MissingField = True
End If
End Function
Code: Select all
Sub Test()
If MissingField("tblReceipts", "privateuse") Then
MsgBox "Please install update", vbCritical
End If
End Sub
Best wishes,
Hans
Hans
-
- BronzeLounger
- Posts: 1488
- Joined: 05 Feb 2010, 22:25
Re: Checking to look if field is in a table
Thanks Hans! Worked like a charm!
Have a great day,
Leesha
Have a great day,
Leesha