×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Naming a DBF
2

Naming a DBF

Naming a DBF

(OP)
Hi, I am trying to name a dbf from a textbox, but I could not find the answer. Please if you can help me. So I want to copy some records from original dbf to another, and name the new one myself by inserting a name in a textbox on a form. This should happen when I press a button on a form.

Thank you. :)

RE: Naming a DBF

lcFilename = ForceExt(yourtextbox.value,'dbf')
Copy from yoursourcetable.dbf to (lcFilename) 

RE: Naming a DBF

Depends a bit, Tore's code would copy the whole table, you may add a FOR clause, but then this limits what you may be able to do.

If you already picked data you want to copy and have it in a cursor, you could SELECT thatcursor and COPY TO (yourtextbox.value), DBF extension is automatic. You'll just need to watch out the name is a valid file name, but assuming you do this for yourself you'll know what to type in. That scratches a bit of the detail you may want to put into code rather than doing such stuff manually as the developer using the VFP IDE as your user interface.

If you want a structural empty copy to later add records you can do many things from AFIELDS and CREATE TABLE FROM ARRAY, which enables you to modify the array. You could SELECT * FROM OriginalTable WHERE .F. INTO TABLE newtable or you could COPY STRUCTURE, which perhaps is the simplest form of copying a table structure or some fields of it.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: Naming a DBF

Just to make it clear; my answer was not meant to give a complete and perfect solution. And I didn't, on purpose, give a huge number of samples and I didn't mention every possible option.

Instead it was meant as a guidance, or push, in the right direction.

My strong belief is that a short and simple question should result in a short and simple answer. I see way too many times where a simple question gets a huge number replies, and with way too much details than necessary to get the initial problem solved. I think all the details way too often confuse more than they help.

RE: Naming a DBF

It's amazing to see how some individuals come across on this forum and contradict themselves:

Quote:

"Unfortunately, since you "wear a mask" by not using your real name, you are not qualified to get any assistance from me."

https://www.tek-tips.com/viewthread.cfm?qid=178030...

Still wondering why Tore Bleken does this for some on other multiple threads as on this thread and not others unless of course VanGoghNS is his or her real name.

Apologies, but my post has nothing to do with this thread but I just wanted to highlight this response:

Quote:

"My strong belief is that a short and simple question should result in a short and simple answer. I see way too many times where a simple question gets a huge number replies, and with way too much details than necessary to get the initial problem solved. I think all the details way too often confuse more than they help."

Well I suppose Tore (I trust that is your real name) that you had to learn this great software application language once and unless I'm missing something, this is a forum to "HELP" people (Yes I shouted). Just get over it, some of us don't need the answer, we just need some positive guidance and "way too much detail" can often be the required assistance some of us need to pick the bones out of and come up with something positive. Olaf and Mike Lewis are the perfect individuals together with other valued members who do this.

By the way, may name is Steve Williams, got it? Steve Williams.

Thank you

Steve Williams
VFP9, SP2, Windows 10

RE: Naming a DBF

OK, I take your hint. It's clearly not allowed to have personal opinions, and heaven forbid, to express them. And it's also clearly not allowed to change one's mind or depart from opinions expressed earlier (due mostly to strict warnings received by personal email).

Especially since I have been warned NOT to try to change anything on this forum, I get the point. So, due to my personal right to act upon my own feelings, I will refrain from providing any more help on this forum, so this is my last posting.

I will be available at Foxite if anyone want's my help in the future.

RE: Naming a DBF

And pick your teddy up on the way out Tore....

Thank you

Steve Williams
VFP9, SP2, Windows 10

RE: Naming a DBF

Sorry to hear that Tore, you have done a lot of good here.
For what it's worth, I don't think any of the people here, meant anything bad towards you. I know I don't...

RE: Naming a DBF

Tore,

nobody argued your answer is wrong. But I don't see why I shouldn't add to it. I see your answer more in defense than in criticising my answer, I take no offense on this remark, it's up to others to see fit in your or my or both answers. Many other things would have made sense, like first asking what the situation is at the point VanGoghNS wants to copy the table. It even makes sense to ask why to copy a table at all, because I usually work with a database of a fixed set of tables without adding tables at all, data in memory is in cursors and then you may also use arrays.

Steve questions your name, not knowing you were a VFP MVP like so many of us here. But yes, Dave Murphy makes rules here about clear names or not, for example, and he decided against such rules. Despite the bad time tek-tips faced with many new accounts turning out to be spammers or worse. Not even mainly here.

If you go, your last act here was offending after being offended. Not that I never did act like that myself, but I now just let time pass before reacting. We don't have to end up with the same convictions. I respect your decision, I'd also respect if you came back.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: Naming a DBF

I'm also sorry to see you go, Tore, although I understand your reasons. I wonder if things are better over on Foxite. I hope so.

Perhaps you will consider coming back afte the dust has settled.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Naming a DBF

(OP)
I am sorry I caused this argument now. Second I still didn't get the chance to try your suggestions, I will try tomorrow. I am an accountant, and we use mfoxplus, so i created several smaller and simple vfp exe that are doing some basic changes like SET FILTER TO, REPLACE ALL etc... So now I want to be able to extract part of the original dbf by number of a specific client, so i did
SET FILTER TO FIRMA=THISFORM.TEXT1.VALUE
COPY TO and here i am missing the part that I want to name a new table as i write in a text2. When I try with THISFORM.TEXT2.VALUE, it just saves my new dbf under a name THISFORM.TEXT2.VALUE I would simply write that in a command line, a new name, but I have some colleagues that are not familiar with that, so i wanted to make that happen. I am not a programmer, I still have a lot to learn, you guys are a great help.
I am sorry again for taking your time, thank you for your help.
Doris Ćulibrk

RE: Naming a DBF

Ah, thanks for that feedback.

What you tried didn't work, as COPY TO takes a filename literally even without putting it in quotes, so: How do you use a variable or object property? That's what Tore shows: You put brackets around them. This is called name expression. So the brackets act a bit like quotes, I'd rather say they act like a forced EAVALuation of the expression in brackets.

Notice: You already had aa more concrete question than you posted. It helps very much, if you tell what you tried and post code you tried.

Why extract data to hand it over? A database is there to share data, you share a frontend querying/filtering it as necessary. It's up to you, but just a simple warning: Copying over data into new files creates an ad-hoc data table that has a nondetermined lifetime that may outlive the time it's true. If someone, no matter if developer or technical user, helpdesk or manager needs a list of data, the current situation will not change by the second, but you have a database to persist the current truth there and you should always prefer to get your data directly from it, so what you share is a query configurable with a parameter or an application doing that query and displaying the result. And for that matter you use SQL INTO CURSOR. If that data is then needed for data exchange, exported, then that could be done at that point, but more usual exchange formats are CSV, XML or JSON, maybe even an excel sheet, but very likely not DBF.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: Naming a DBF

(OP)
Sorry for the misunderstanding, thank you so much for your help, I will try this tomorrow. I understand what you mean, I will do a better research in the future. Thanks again.
Doris Ćulibrk

RE: Naming a DBF

No, this isn't about better research. It's not so obvious variable or object property names in commands are not interpreted as variables and properties and their values. That also is quite buried in the help. And it's a problem constructed into the language by its history. You find lots of places, of course specifically functions, which also take a file name as a parameter and there you can't write a literal name without quotes. This is very unusual in VFP and so that's not the problem with the quality of your question.

It would just have been much more obvious what you want and need to know if you had posted your try to COPY TO THISFORM.TEXT2.VALUE.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: Naming a DBF

(OP)
I got it with Tore's suggestion. Thanks again guys.

Doris Ćulibrk

RE: Naming a DBF

Tore,
did you have a bad sleep? C'on dont let one critic bother you. Wether the critic is right or wrong, just keep up the spirit. Man we do appericiate your contributions.
--

Doris,
you can easily change your alias VanGogh, one of my favorite Dutch painters, into your real name, if you like

Regards,

Koen

RE: Naming a DBF

Tore,

I like to read your straight forward contributions here too, just like Koen. Some members show elaborate solutions as an alternative, what I appreciate as well. It just shows that VFP can be used in many different ways.

I hope that as long as I live I will keep learning from others.

Regards, Gerrit

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close