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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xml, html and Access - reading and writing 101 intro 1

Status
Not open for further replies.

SBendBuckeye

Programmer
May 22, 2002
2,166
US
I know that Access has a save as HTML option and if taken it will save a table definition, table data, etc as HTML. I know enough to basically follow it although I have never had to use it.

We are working on an Access DLL which needs to save some default data values, etc and one of the .net guys said I should use XML to save that data and then just read it back in whenever I need it.

How do I read it back in? Do I manually read in the text file a line at a time and parse the information based on the various <tag> and </tag> combinations I find or (say in the case of a table) can I actually import it directly into a table? If so, do I need to create the table first (actually what I really need is a temporary cursor, I think).

Am I way off base here, should I be doing something else, or whatever? Thanks in advance for any help you can give me!

Have a great day!
 
You can download the XML object and find out info about it here...


Now I have a question that might help you...

What type of default data are you saving and can you save it and call it from the database?

With XML you can enumerate through the properties/elements of the XML document just as you would enumerate a collection or the properties of an object.

I Hope this helps, good luck
 
Thanks for a nice get started spot. Here is an idea of what I am trying to do. Your comments and suggestions would be greatly appreciated.

I have developed some specialized processing which I use to standardize my forms and give them a uniform look and feel. This is currently implemented via the tag property on the various form controls.

As an example, one control may be hidden in update mode but visible in non-update mode or vice versa (say a combo box for query mode which is hidden so a text box underneath it is visible during update mode). A couple other examples are required fields, update mode initial focus, non-update mode initial focus or default value not valid (eg on a tight form which is self evident without labels when data is present, I may make the default value &quot;Last Name&quot; or &quot;First Name&quot;, etc). Behind the scenes I make heavy use of spinning the form controls collections matching up to a control properties array I crate at form load time by reading tags.

There are limitations to this approach. If I implemented it with tables I would just save and update various fields in the tables with this information and read it out of the form load code.

But I would really like to convert this to a class and ultimately to a DLL. To do that I need a way to store and retrieve the data for the various forms in a system.

Your post was very helpful and your last paragraph really caught my eye when you said you can enumerate properties in XML. That is exactly what I think I want to do. Would this be similar to spinning the database containers documents collection or one of the other collections.

I hope I have been at least a little bit clear about what I am trying to accomplish. Thanks for our help already!

Have a great day and weekend!
 

I have lots of thoughts but I am not sure that any of them are right for what you are trying to describe in doing (basically I am not sure what you are trying to do). So I will go with this suggestion. If the dll you are making is going to be a tier in a multi tier system then I would suggest that you do not keep any data within it. Use the database for default values or some other type of file that you can change without having to change the dll. One note about using the database for default values, if you have several &quot;customers&quot; and you want to create different default values for each then the database will be easier to keep this information.

I don't know if this helps but I hope it does.

Good Luck

 
Sorry, I did not communicate very well. I know that you cannot keep any data in the DLL itself. Please bear with me and I will give an example, perhaps that will clarify things for you and/or others.

Let's say I have 2 additional things that I check for a given form control, is the control required (if so then do not accept vbNullString for strings or 0 for numerics) and should the control accept the default value (eg Last Name or SSN - this allows the default value to be an in data prompt on tight screens).

Currently this is implemented in the control tags which are read into an array when the form is loaded (eg tag1 = Required;, tag2 = AllowDefault;, tag3 = Required; AllowDefault;, etc). That means control1 must be entered, control2 can use the default value and control3 must be entered and can use the default value.

If I was going to implement this in a table, I would have something like the following:

tblSpecCaseProp
PropID - Numeric
PropName - Text
PropType - Text (numeric, string, boolean, etc)

Records
1, Required, Boolean
2, AllowDefault, Boolean

tblSpecCaseCtl
KeyID - Numeric
PropID - Numeric - from tblSpecCaseProp
FrmName - Text
CtlName - Text
CtlValue

Records
1, 1, frmPat, LastName, True
2, 2, frmPat, LastName, False
3, 1, frmPat, FirstName, True

4, 1, frmDoc, LastName, False
5, 1, frmDoc, FirstName, True
6, 2, frmDoc, FirstName, True

Above would mean that on frmPat, LastName is required and does NOT allow the default value while FirstName is required. On frmDoc, LastName is NOT required but FirstName is required and does allow a default value.

If I was loading frmPat, I would gather this information into an array with SQL like the following:

SELECT PropName, CtlName, CtlValue
FROM tblSpecCaseProp AS sp INNER JOIN tblSpecCaseCtl AS sc
ON sp.PropID = sc.PropID
WHERE FrmName = 'frmPat';

If I use the SaveAsHTML option, I get something like the following for tblSpecCaseCtl:

<THEAD>
<TR>
<TH BGCOLOR=#c0c0c0 BORDERCOLOR=#000000 ><FONT SIZE=2 FACE=&quot;Arial&quot; COLOR=#000000>KeyID</FONT></TH>
<TH BGCOLOR=#c0c0c0 BORDERCOLOR=#000000 ><FONT SIZE=2 FACE=&quot;Arial&quot; COLOR=#000000>PropID</FONT></TH>
<TH BGCOLOR=#c0c0c0 BORDERCOLOR=#000000 ><FONT SIZE=2 FACE=&quot;Arial&quot; COLOR=#000000>FrmName</FONT></TH>
<TH BGCOLOR=#c0c0c0 BORDERCOLOR=#000000 ><FONT SIZE=2 FACE=&quot;Arial&quot; COLOR=#000000>CtlName</FONT></TH>
<TH BGCOLOR=#c0c0c0 BORDERCOLOR=#000000 ><FONT SIZE=2 FACE=&quot;Arial&quot; COLOR=#000000>CtlValue</FONT></TH>

</TR>
</THEAD>

Since this is nothing but a text file, I would prefer to use this method and just save the information to a file and then read it in when I need to use it.

But the piece I am missing is, when I read the above HTML in during form load processing, can I read it directly into an array somehow, or do I need to create a temporary table to read it into directly or do I have to process it a line at a time as a text file and then manually parse it.

Thanks again for your responses and help! I hope this is a little bit clearer that my earlier response.

Have a great day!




 
Can anyone help me on this. How do you read the file back into Access for processing?

Thanks in advance!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top