Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Naming a DBF 2

Status
Not open for further replies.

VanGoghNS

IS-IT--Management
Mar 19, 2019
4
RS
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. :)
 
[pre]lcFilename = ForceExt(yourtextbox.value,'dbf')
Copy from yoursourcetable.dbf to (lcFilename)[/pre]
 
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 [tt]SELECT thatcursor[/tt] and [tt]COPY TO (yourtextbox.value)[/tt], 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 [tt]AFIELDS[/tt] and [tt]CREATE TABLE FROM ARRAY[/tt], which enables you to modify the array. You could [tt]SELECT * FROM OriginalTable WHERE .F. INTO TABLE newtable[/tt] or you could [tt]COPY STRUCTURE[/tt], which perhaps is the simplest form of copying a table structure or some fields of it.

Bye, Olaf.

Olaf Doschke Software Engineering
 
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.
 
It's amazing to see how some individuals come across on this forum and contradict themselves:

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


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:

"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
 
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.
 
And pick your teddy up on the way out Tore....

Thank you

Steve Williams
VFP9, SP2, Windows 10
 
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...
 
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
 
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
 
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
 
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
 
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
 
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
 
I got it with Tore's suggestion. Thanks again guys.

Doris Ćulibrk
 
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
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top