By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,203 Members | 1,383 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,203 IT Pros & Developers. It's quick & easy.

couple of 2003 questions on code

P: n/a
I was converting this from 97 to 2003 and ran into a problem in the
code.

The problem is fld.name
name highlighted and says method or member not found.

I have seen this work for years what is up with fld.Name
fld. does not have Name a selection
is it the set db command that has this screwed up in 2003?

Dim tdf As TableDef
Dim db As Database
Dim fld As Field
Dim prp As Property
Dim pos As Integer
Dim repl, replwith As String
Dim repldesc, repldescwith As String
Dim tname As String

Set db = CurrentDb
tname = InputBox("in which table")

repl = InputBox("Replace in name what")
replwith = InputBox("in name with what")

repldesc = InputBox("Replace in desc what")
repldescwith = InputBox("in desc with what")

For Each tdf In db.TableDefs

If ((Left(tdf.Name, 4) <"MSys") And (Format(Left(tdf.Name, 1),
">") <"z")) And _
(InStr(1, Format(tdf.Name, ">"), "switchboard") = 0) Then

If tdf.Name = tname Or tname = "ALL" Then
For Each fld In tdf.Fields
' fld.DefaultValue = 0
pos = InStr(fld.Name, repl)
If pos 0 Then
fld.Name = Left(fld.Name, pos - 1) & replwith &
Right(fld.Name, Len(fld.Name) - pos - Len(repl) + 1)
End If
For Each prp In fld.Properties
If prp.Name = "Description" Then
pos = InStr(prp.Value, repldesc)
If pos 0 Then
prp.Value = Left(prp.Value, pos - 1) & repldescwith &
Right(prp.Value, Len(prp.Value) - pos - Len(repldesc) + 1)
End If
End If
Next
Next
End If
End If
Next

Jan 3 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Make sure you have all the proper references created. (i.e. in the code
editor, click Tools -References)

sparks wrote:
I was converting this from 97 to 2003 and ran into a problem in the
code.

The problem is fld.name
name highlighted and says method or member not found.

I have seen this work for years what is up with fld.Name
fld. does not have Name a selection
is it the set db command that has this screwed up in 2003?

Dim tdf As TableDef
Dim db As Database
Dim fld As Field
Dim prp As Property
Dim pos As Integer
Dim repl, replwith As String
Dim repldesc, repldescwith As String
Dim tname As String

Set db = CurrentDb
tname = InputBox("in which table")

repl = InputBox("Replace in name what")
replwith = InputBox("in name with what")

repldesc = InputBox("Replace in desc what")
repldescwith = InputBox("in desc with what")

For Each tdf In db.TableDefs

If ((Left(tdf.Name, 4) <"MSys") And (Format(Left(tdf.Name, 1),
">") <"z")) And _
(InStr(1, Format(tdf.Name, ">"), "switchboard") = 0) Then

If tdf.Name = tname Or tname = "ALL" Then
For Each fld In tdf.Fields
' fld.DefaultValue = 0
pos = InStr(fld.Name, repl)
If pos 0 Then
fld.Name = Left(fld.Name, pos - 1) & replwith &
Right(fld.Name, Len(fld.Name) - pos - Len(repl) + 1)
End If
For Each prp In fld.Properties
If prp.Name = "Description" Then
pos = InStr(prp.Value, repldesc)
If pos 0 Then
prp.Value = Left(prp.Value, pos - 1) & repldescwith &
Right(prp.Value, Len(prp.Value) - pos - Len(repldesc) + 1)
End If
End If
Next
Next
End If
End If
Next
Jan 3 '07 #2

P: n/a
This is probably a References ambiguity.

In the code window, choose References on the Tools menu.
Deselect the Microsoft ActiveX Data Objects library.
Make sure the Microsoft DAO 3.6 Library is selected.

Alternatively, be explicit about which Field you want, e.g.:
Dim fld As DAO.Field
Dim prp As DAO.Property

More info on references for each version of Access:
http://allenbrowne.com/ser-38.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"sparks" <js******@swbell.netwrote in message
news:pn********************************@4ax.com...
>I was converting this from 97 to 2003 and ran into a problem in the
code.

The problem is fld.name
name highlighted and says method or member not found.

I have seen this work for years what is up with fld.Name
fld. does not have Name a selection
is it the set db command that has this screwed up in 2003?

Dim tdf As TableDef
Dim db As Database
Dim fld As Field
Dim prp As Property
Dim pos As Integer
Dim repl, replwith As String
Dim repldesc, repldescwith As String
Dim tname As String

Set db = CurrentDb
tname = InputBox("in which table")

repl = InputBox("Replace in name what")
replwith = InputBox("in name with what")

repldesc = InputBox("Replace in desc what")
repldescwith = InputBox("in desc with what")

For Each tdf In db.TableDefs

If ((Left(tdf.Name, 4) <"MSys") And (Format(Left(tdf.Name, 1),
">") <"z")) And _
(InStr(1, Format(tdf.Name, ">"), "switchboard") = 0) Then

If tdf.Name = tname Or tname = "ALL" Then
For Each fld In tdf.Fields
' fld.DefaultValue = 0
pos = InStr(fld.Name, repl)
If pos 0 Then
fld.Name = Left(fld.Name, pos - 1) & replwith &
Right(fld.Name, Len(fld.Name) - pos - Len(repl) + 1)
End If
For Each prp In fld.Properties
If prp.Name = "Description" Then
pos = InStr(prp.Value, repldesc)
If pos 0 Then
prp.Value = Left(prp.Value, pos - 1) & repldescwith &
Right(prp.Value, Len(prp.Value) - pos - Len(repldesc) + 1)
End If
End If
Next
Next
End If
End If
Next
Jan 3 '07 #3

P: n/a
Thanks to both of you...I turned off activeX data objects library
and got the same error.

I then tried Dim fld As DAO.Field and Dim prp As DAO.Property
worked like a charm.

thanks again
On Thu, 4 Jan 2007 01:47:56 +0800, "Allen Browne"
<Al*********@SeeSig.Invalidwrote:
>This is probably a References ambiguity.

In the code window, choose References on the Tools menu.
Deselect the Microsoft ActiveX Data Objects library.
Make sure the Microsoft DAO 3.6 Library is selected.

Alternatively, be explicit about which Field you want, e.g.:
Dim fld As DAO.Field
Dim prp As DAO.Property

More info on references for each version of Access:
http://allenbrowne.com/ser-38.html
Jan 3 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.