473,396 Members | 1,967 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,396 software developers and data experts.

couple of 2003 questions on code

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
3 1311
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: bjs | last post by:
I hope I've got the right group here and apologies if I haven't. I'm a hobby programmer and have just upgraded to Visual Basic.net and have a couple of questions if anybody can help. In VB 6...
1
by: Novice | last post by:
Hi all, I'm afraid this is the second posting of this information as I didn't get a response on the previous post. I will try to shorten my message (i.e. be more concise) in the hopes that it will...
21
by: Rob Somers | last post by:
Hey people, I read a good thread on here regarding the reason why we use function prototypes, and it answered most of my questions, but I wanted to double check on a couple of things, as I am...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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?
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.