Microsoft Access Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft Access Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old January 27th, 2004, 05:27 AM
FENSTER FENSTER is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 6 FENSTER User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
help with path insert

Hi Guys , this is my first post (so be gentle)!

I have an access table .. its my wifes karaoke catalogue.

i have to change field 3 and i think there must be a way to do this rather than manually....

heres my problem

field 1 : song title
field 2: artist
field 3 : disc number (example : SFG002-01)

field 3 records run like :

SFG002-02
SFG002-03
SFG002-04


i want to change this field :
from SFG002-02 to
C:\KARAOKE\SF002\SFG002-02

from SFG010-02 to
C:\KARAOKE\SF010\SFG010-02

from SFG100-02 to
C:\KARAOKE\SF100\SFG100-02

what i want is vba code that can "read" the 3 digit number after the G in SFG and insert a relevant path before the catalogue number : c:\karaoke\sf***\

i could copy /paste and manually change but theres loads!
im also very curious as to if it can be done, i find myself with a similar task every few months...


hoping some1 can help..

thanks

davie.

Last edited by FENSTER : January 27th, 2004 at 05:36 AM.

Reply With Quote
  #2  
Old January 27th, 2004, 11:53 AM
sbaxter sbaxter is offline
Moderator: Access, SQL
ASP Free God (5000 - 5499 posts)
 
Join Date: Oct 2003
Posts: 5,126 sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 1 h 2 m 51 sec
Reputation Power: 13
NewField3 = "C:\KARAOKE\SF" & mid(Field3,3,3) & "\" & Field3

S-

Reply With Quote
  #3  
Old January 28th, 2004, 07:07 AM
FENSTER FENSTER is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 6 FENSTER User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks S

this code looks excellent,

do i put it in a macro then run?
or can i use an update query?

Last edited by FENSTER : January 28th, 2004 at 07:14 AM.

Reply With Quote
  #4  
Old January 28th, 2004, 10:53 AM
sbaxter sbaxter is offline
Moderator: Access, SQL
ASP Free God (5000 - 5499 posts)
 
Join Date: Oct 2003
Posts: 5,126 sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 1 h 2 m 51 sec
Reputation Power: 13
I woud use this portion

"C:\KARAOKE\SF" & mid(Field3,3,3) & "\" & Field3

as an expression in an update query

S-

Reply With Quote
  #5  
Old January 28th, 2004, 11:12 AM
FENSTER FENSTER is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 6 FENSTER User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Put your code in an update statement and ran it:

instead of :SFG002-02

i now have : C:\KARAOKE\SFeld\Field3

am i missing something/doing the update wrong?

Reply With Quote
  #6  
Old January 28th, 2004, 11:53 AM
sbaxter sbaxter is offline
Moderator: Access, SQL
ASP Free God (5000 - 5499 posts)
 
Join Date: Oct 2003
Posts: 5,126 sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 1 h 2 m 51 sec
Reputation Power: 13
YES

"C:\KARAOKE\SF" & mid(Field3,3,3) & "\" & Field3

Field3 - is the name of the field that the existing information is being stored. You have to change that to reflect your system


S-

Reply With Quote
  #7  
Old January 28th, 2004, 12:07 PM
FENSTER FENSTER is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 6 FENSTER User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
i changed the field3 to path

"C:\KARAOKE\SF" & Mid("path",3,3) & "\" & "path"

heres what i got:

C:\KARAOKE\SFth\path

if i change it to karaokep :

"C:\KARAOKE\SF" & Mid("karaokep",3,3) & "\" & "karaokep"

C:\KARAOKE\SFrao\karaokep


my method is to create an update query,
field : karaokep
table: sunfly
update to : "C:\KARAOKE\SF" & Mid("karaokep",3,3) & "\" & "karaokep"


i see what the query is doing - reading the actual text instead of the field contents......

Reply With Quote
  #8  
Old January 28th, 2004, 12:36 PM
sbaxter sbaxter is offline
Moderator: Access, SQL
ASP Free God (5000 - 5499 posts)
 
Join Date: Oct 2003
Posts: 5,126 sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 1 h 2 m 51 sec
Reputation Power: 13
Change the " " to []

S-

Reply With Quote
  #9  
Old January 28th, 2004, 01:09 PM
FENSTER FENSTER is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 6 FENSTER User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
query must have at least one destination field.......

"C:\KARAOKE\SF" & Mid([Field3],3,3) & "\" & [Field3]

think ur getting there

Reply With Quote
  #10  
Old January 28th, 2004, 01:18 PM
sbaxter sbaxter is offline
Moderator: Access, SQL
ASP Free God (5000 - 5499 posts)
 
Join Date: Oct 2003
Posts: 5,126 sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 1 h 2 m 51 sec
Reputation Power: 13
Send in the SQL code of your update statement


(SQL view of your query)
S-

Reply With Quote
  #11  
Old January 28th, 2004, 04:42 PM
FENSTER FENSTER is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 6 FENSTER User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thanks sbaxter,

u got me there in the end and it saved me loads of copy/paste/find/replace!!

one thing -

UPDATE sunfly SET sunfly.path3 = "C:\KARAOKE\SF" & Mid([path3],3,3) & "\" & [path3];

gave me
C:\KARAOKE\SFG01\SFG011-11

character missing - sfg01 should have been sfg011

so i changed mid 3,3 to 3,4 and it was fine..

why is this?

Reply With Quote
  #12  
Old January 28th, 2004, 04:47 PM
sbaxter sbaxter is offline
Moderator: Access, SQL
ASP Free God (5000 - 5499 posts)
 
Join Date: Oct 2003
Posts: 5,126 sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 1 h 2 m 51 sec
Reputation Power: 13
Mid([path3],3,3)

The first three says "what position do I start in"

The second three says "go over 3 spaces"


The original question only gave example that need three so that is why I gave you 3 up it sounds like it works with 4 so good luck

S-

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft Access Help > vba code needed for path insert


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT