473,406 Members | 2,390 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,406 software developers and data experts.

Multiple pastes

sds
Hi all - newbie here - tried to find the answer to this question but
failed - hope someone here can help. It should be a simple question so maybe
I'm making life harder than it needs to be.

I use MS Access 2002 - and have numerous tables that I have to paste in the
same text string. How can I do it so I don't have to paste 200 times - is
there a way to copy my text, highlight the cells I want to paste it into,
and then have my text string appear in all 2000 cells? Is there a way to do
this?

Thanks.

Simon
Nov 13 '05 #1
5 1247
Sounds like a dodgy database design. I can't think of an instance in
which I've needed to do this. If you're doing it across a definable
set of records in a single table, use an update query. What you're
describing sounds like you're coming from the world of Excel, and
Access and Excel are radically different.

So describe your database tables - just the ones you want to paste this
string into, and the overall design. (no need for lots of details -
keep it short and sweet.)

Nov 13 '05 #2
Hey - thanks.

The db has multiple tables, each with a list of items, ID #'s, description
and an image location cell...........this is basically the basis for a drill
down db to be put on the web. I want to have the image location cell be the
same default image location until such time as an item specific image is
uploaded.

Thanks again!

Simon
<pi********@hotmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Sounds like a dodgy database design. I can't think of an instance in
which I've needed to do this. If you're doing it across a definable
set of records in a single table, use an update query. What you're
describing sounds like you're coming from the world of Excel, and
Access and Excel are radically different.

So describe your database tables - just the ones you want to paste this
string into, and the overall design. (no need for lots of details -
keep it short and sweet.)

Nov 13 '05 #3
You can try this, it worked once upon a time ;)... Be sure to (1) watch
out for spurious line breaks, (2) set a reference to the DAO library,
and (3) pay attention to that warning in the update-writer about value
types in the fields. (I'd have added that code too, but it was getting
out of hand as it was.)

Oh and it won't help much if you have fifty different field names, but
since you spoke of drill-downs it should get you started at least. You
can loop through all fld in rst.Fields almost as easily. It won't be
fast.

'*** CODE START ***
Public Function ReplaceFldValueInAllTbls(ByVal pstrFldNm As String, _
ByVal pvarValueToFind As
Variant, _
ByVal pvarReplacement As
Variant) As String
'On Error GoTo HandleErrors

Dim obj As AccessObject
Dim dbs As Object

Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim fld As DAO.Field
Dim qdf As DAO.QueryDef

Dim strSQL As String
Dim strResult As String

Dim strLkupTbl As String
Dim strFldsLst As String
Dim bleUpdateFld As Boolean
Dim strUpdateTblFld As String

Dim strMsg As String
Dim varResponse As Variant

Dim varSysCmd As Variant
Dim intCount As Integer
Dim i As Long

Set dbs = Application.CurrentData

Set db = CurrentDb

For Each obj In dbs.AllTables
varSysCmd = SysCmd(acSysCmdInitMeter, "searching tables for " &
pstrFldNm & "...", dbs.AllTables.Count)

bleUpdateFld = False
strUpdateTblFld = ""
Set rst = db.OpenRecordset(obj.Name, dbOpenSnapshot,
dbForwardOnly)

For Each fld In rst.Fields
If fld.Name = pstrFldNm Then
strUpdateTblFld = obj.Name & "." & fld.Name
If InStr(1, strFldsLst, strUpdateTblFld) = 0 Then
bleUpdateFld = True
Else
bleUpdateFld = False
End If
ElseIf InStr(1, fld.Name, pstrFldNm, vbBinaryCompare) > 0
Then
strUpdateTblFld = obj.Name & "." & fld.Name
If InStr(1, strFldsLst, strUpdateTblFld) = 0 Then
strMsg = "Replace values in " & strUpdateTblFld &
"?"
varResponse = MsgBox(strMsg, vbYesNo Or vbQuestion,
"partial field-name match")
bleUpdateFld = (varResponse = vbYes)
Else
bleUpdateFld = False
End If
Else
bleUpdateFld = False
End If

If bleUpdateFld = True Then
strFldsLst = strFldsLst & ", " & strUpdateTblFld
'write an
strSQL = usqlWriteSimpleUpdate(obj.Name, fld.Name,
pvarValueToFind, pvarReplacement)
Set qdf = db.CreateQueryDef("", strSQL)

qdf.Execute
i = qdf.RecordsAffected
If i > 0 Then
strMsg = strUpdateTblFld & ": " & i & " record(s)
updated." & strMsg
strResult = strResult & vbNewLine & strMsg
Else
strResult = strResult & vbNewLine & strUpdateTblFld
& " - no matches found"
End If
End If
Next fld

intCount = intCount + 1
varSysCmd = SysCmd(acSysCmdUpdateMeter, intCount)
Next obj

ReplaceFldValueInAllTbls = strResult

ExitHere:
Set qdf = Nothing
Set fld = Nothing
Set obj = Nothing
Set db = Nothing
Set dbs = Nothing
varSysCmd = SysCmd(acSysCmdRemoveMeter)

Exit Function

HandleErrors:
'do it
Resume ExitHere

End Function

Public Function usqlWriteSimpleUpdate(pstrTblQryNm As String, _
pstrFldNm As String, _
pvarValueToFind As Variant, _
pvarReplacementValue As Variant)
As String
On Error GoTo HandleErrors

Dim strUpdateTblFld As String

strUpdateTblFld = pstrTblQryNm & "." & pstrFldNm

'CAUTION: this assumes numerical pvarValueToFind !!!!!
'i.e. strings need "", dates need ## and in the right order, etc.,
to make valid SQL

usqlWriteSimpleUpdate = "UPDATE " & pstrTblQryNm & " SET " &
strUpdateTblFld & " = " & pvarReplacementValue & vbNewLine _
& "WHERE (" & strUpdateTblFld & " = " &
pvarValueToFind & ");"
ExitHere:
Exit Function

HandleErrors:
'do it
Resume ExitHere

End Function
'*** CODE END ***

Nov 13 '05 #4
FWIW, it sounds like you can simplify this a lot. Just add a field to
differentiate the various records (like having the group that the item
belongs to). Then you could have one table and an infinitely simpler
and more flexible design.

Nov 13 '05 #5
simon <sd*@sdc.com> wrote:

: The db has multiple tables, each with a list of items, ID #'s, description
: and an image location cell.....this is basically the basis for a drill
: down db to be put on the web. I want to have the image location cell be the
: same default image location until such time as an item specific image is
: uploaded.
Why don't you just leave the image location cell empty and have
code that uses the contents of the image location cell if filled,
and a preset variable containing the default if it's empty?
--thelma

: Simon
Nov 13 '05 #6

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

Similar topics

6
by: Rolf Wester | last post by:
Hi, I have a form with a select element with multiple="true". When using the GET method (I suppose the same happens with the POST method) I can seen that the form sends channels=CH1&channels=CH2...
66
by: Darren Dale | last post by:
Hello, def test(data): i = ? This is the line I have trouble with if i==1: return data else: return data a,b,c,d = test()
11
by: Ohaya | last post by:
Hi, I'm trying to understand a situation where ASP seems to be "blocking" of "queuing" requests. This is on a Win2K Advanced Server, with IIS5. I've seen some posts (e.g.,...
6
by: Ben Hallert | last post by:
Hi guys, I'm trying to figure out what bone headed mistake I made on something I put together. I've got a form (named 'context') that has a variable number of select-multiple inputs on it. ...
4
by: John Doe | last post by:
I am interested in creating a database of my mp3 files. What I am looking to do is paste a series of lines of text into a series of table cells in access. Every time I try to do it, it pastes ALL...
22
by: Matthew Louden | last post by:
I want to know why C# doesnt support multiple inheritance? But why we can inherit multiple interfaces instead? I know this is the rule, but I dont understand why. Can anyone give me some concrete...
9
by: Abhishek Srivastava | last post by:
Hello All, In IIS 6.0 We have a concept of worker processes and application pools. As I understand it, we can have multiple worker process per appliction pool. Each worker process is dedicated...
9
by: Graham | last post by:
I have been having some fun learning and using the new Controls and methods in .Net 2.0 which will make my life in the future easier and faster. Specifically the new databinding practises and...
35
by: keerthyragavendran | last post by:
hi i'm downloading a single file using multiple threads... how can i specify a particular range of bytes alone from a single large file... for example say if i need only bytes ranging from...
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: 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:
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.