UKnod 16 Newbie Poster

Unfortunatly that example is writen in c# and I use .net. However I think I get the jist, basically there is no single sql statement, instead you get a list of tables and then search in each table in turn.

UKnod 16 Newbie Poster

I solved this my self in the end. What you have to do is make a seperate function that contains a OleDb.OleDbCommandBuilder and an update comanad.
This then updates the real database and not the one loaded into memnory. Seems like an od way to do things but it works.

UKnod 16 Newbie Poster

I have an access database which I am using with .net, I can search tables and maker very specific searches no problem, trouble is that I can't work out how to make global searches. IE search entire databse for "fred" or search a single table for "fred". Anyone know what the SQL string might look like:

UKnod 16 Newbie Poster

Hi
Yes I have 12 tabs, yes so tab 6 is the 7th one.
I have now figured out how to do this, and it seems that you can't use an index to remove tabs, you can use it for pretty much everything else but not remove.
So here is how I got it to work:

Tabcontrol1.TabPages.Remove(Tagname1)
Tabcontrol1.TabPages.Remove(Tagname2)
'etc
Tabcontrol1.TabPages.Remove(Tagname7)
UKnod 16 Newbie Poster

Whilst I thought it was working I have now come accross another problem. Your code works great upto the 5th tab, then I get an error:
InvalidArgument=Value of '6' is not valid for 'index'. Parameter name: index
Its almost like it thinks tabcontrol tabpages is a real array that has not been declared.
Any ideas.

UKnod 16 Newbie Poster

I have finally fixed it, and the fix was far to compecated to explain and I doubt would be much use to anyone as it was a human error as usual. As the original posting was fixed I will now close off this discussion.
Thanks to Qveen72 for the solution to removing the tab. One last interesting thing is that when I posted that his solution wasn't working, this was true and it was becasue of a completely obscure problem with a sql statement when accessing an access database, its worth remembering that something completely seperate can cause things to not work which are seemingly unrelated.

UKnod 16 Newbie Poster

I dont know what is happening with my programme. But it has now decided to work. I have made no changes since it was not working, but I was working in Access in another window, which is now closed. However even when I open access my programme still works. Very odd.
And if you want realy odd, I am now stuck on the wierdest fault I have ever encountered.
Here goes:
When opening an access DB using the following ver simple code:

ds.Tables("tblList").Rows(0).Item(1)

I inserts row 7

However if I use this code:

ds.Tables("tblList").Rows(0).Item("Tab1")

tab1 being the label for field1, it works fine.

to try to find this anomoly, I tried making a new table, same thing hapens. A new database, same thing happens. A copy of an old table - works until I add another field then it stops working again.

I am now just about ready to go smash my head in.

By the way thanks for the earlier solution.

UKnod 16 Newbie Poster

Hi
Sounds good, looks simple, but doesn't work.

UKnod 16 Newbie Poster

I have a problem with vb.net tabcontrol in so far as I cannot change the individual tab widths. I can chang ethe sizecontrol to fixed and alter all of the tabs but not individually. Ordinarily it would not be a problem with the tabs autosizing by the text size, but I have sometimes in my programme tabs with no content which I would like to hide, this I thought would be easy as just give it no name, but the tab remains and the size seems to have a minimum which is too big.

So to summerize. I want to hide dynamically one or more tabs in tabcontrol.

UKnod 16 Newbie Poster

Thank you so much you guys, both options worked a treat so I went with TnTinMN just because it seemed the right way to go.

UKnod 16 Newbie Poster

Sorry, didn't explain very well. arr is a binary data file stored in a database.

What is odd is that loading from a file (as your example) doesn't give the warning, but loading from io.memorystream does. Why?

UKnod 16 Newbie Poster

I have a warning that I can;t get rid of:

Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated.

I am pretty sure it is becasue I have not dimentioned the variable but how do you dimention an IO.memorystream.

Here is the code:

Photograph1.Image = Photograph1.Image.FromStream(New IO.MemoryStream(arr))

Any help would be greatfull. The programms runs and works, its just got those annoying warnings.

UKnod 16 Newbie Poster

Thanks for this. I haven't used your code but I get the gist of it works now. What I was doing wrong was that I couldn't dimention the oDoc (doc) because I was using an unknown template. IE one the user browses to see which was within an if then statement after the dims. So I have moved the if then to encompas the whole sub routine with the dim statements within it, now it works without the warnings.

It was readiong your code that got me to find it and I have changed the way it dimentions the app to your sugestion, I am not sure why it is better but I will take you expertise over mine.

Thanks again.

UKnod 16 Newbie Poster

Hi
Thank you very much for the first part it now works a treat with no errors.

As for the word part, well I have checked the code example and many others but still have not found a solution. Perhaps I had better explain the problem:

Dim oWord As Word.Application
Dim oDoc As Word.Document
oWord = CreateObject("Word.Application")
oDoc = oWord.Documents.Add(OpenFileDialog1.FileName)

All ok so far but when it comes to bookmarks, I think I can only use the Odoc.Bookmarks to use this function. Ie Odoc already has a value and has been used so why do I get the warning when I use

oDoc.Bookmarks("Contact1").Range.Text = Contact1TextBox.Text

I have tried to make a new variable

Dim oBook As Word.Bookmarks

and used

oBook.add("Contact1").Range.Text = Contact1TextBox.Text
But this does not work at all.

A last little help would be great.

oBook

UKnod 16 Newbie Poster
Although the program still run fine I am getting a little tired of the warning on my program that I can't
 get rid of.
 First one is with a process:


          Dim NewProcess As Process = New Process
                 If Attachment2TextBox.Text <> "" Then
                     NewProcess.Start(Attachment2TextBox.Text)


 Here is the warning:
 Warning    5   Access of shared member, constant member, enum member or nested type through an instance;
 qualifying expression will not be evaluated.   
 It gives me the warning on the NewProcess.Start I dont know how else I can use a process!
 The second is using the word interface:


          Dim oDoc As Word.Document
           oDoc.Bookmarks("FirstName").Range.Text = FirstNameTextBox.Text


 heres the warning:
 Warning    6   Variable 'oDoc' is used before it has been assigned a value. A null reference exception
 could eesult at runtime.
 Once again how can I give oDoc a value at dimention?
 Makes no sense to me any how would be apreciated.
UKnod 16 Newbie Poster

Yes, Interesting reading, and it uses VB6, which seems to work fine without the errors. I am trying to use all versions of word, ie 2000,2002,2003,2007 and 2010. But as 2000 and 2002 are too different I have decided to drop them.

I have now managed to convert the errors to warnings by somehow adding the references even though the computer doesn;t have the relevant versions installed, and it seems to work, I will know for sure when I try running the compiled programme on some other machines that only have one version installed, but I think it is going to work.

UKnod 16 Newbie Poster

Not as easy as that, and it is not CRAP code it is CRAP software that doesn't allow for this to work. On VB6 it would have worked fine.
The reason for the errors is because word 2003 needs to have the declared
Imports Word = Microsoft.Office.Interop.Word to work, but 2007 onwards uses a completely different method and doesn;t recognise this statement, and thus the several hundred of statement that uses the "word" variable. The fact is that the compiled programme would never error because the code would route the programme to the correct version installed.

And I cant test on a computer that has 2010 on it as that will then error on the 2003 part of the code. nAnd in any case it is not so much as testing the programme as adding new code to other parts of the programme. I am at a loos as to what to do.

The only method I see available to me is to have a different database programme for each version of work, which seems ridiculous. But it looks like that is the way it has to be, or go back to VB6!

UKnod 16 Newbie Poster

Is there any way of running and compiling with known errors in the code.

Her is my reason. I am using a reference to word 2008 and word 2010, so as the program will work with both versions. Trouble is that if the computer I am using to test the code, only has one installed (naturally) so the program wont compile or run for me to test other parts of the program. There must be a way of ignoring error which wont make any difference to the run time compile program.

UKnod 16 Newbie Poster

thanks for the info, I have tried that already but it refers to VS2002 and wordXP I am using VS2008 and word 2003, so when I try to run that code it doesn't work.

UKnod 16 Newbie Poster

Here is what I am trying to do:
From VB.net open a word template --- Done
Populate it from a database ------Done
Have word report back with the saved file name so as I can add it to the database history ----Not done.

I know is has something to do with the close events in word but I am unable to get it working.
I have made a class which I think should work:

Dim WithEvents wordApplication As New Microsoft.Office.Interop.Word.Application

this gives me a drop down for

Private Sub wordApplication_DocumentBeforePrint(ByVal Doc As Microsoft.Office.Interop.Word.Document, ByRef Cancel As Boolean) Handles wordApplication.DocumentBeforePrint

but I dont know how to invoke this routine.

Any help greatly appreciated.

UKnod 16 Newbie Poster

sorry but backups has nothing to do with this subject?

UKnod 16 Newbie Poster

Yes I tried that, but it does not make any difference.
Odly enough I have writed another console based programe with pretty much the sanme code, and that does work.
What is the difference?

UKnod 16 Newbie Poster

I have a problem with retrieving data from access databse.
I make the connection and retrieve the data no problem. But when the data changes from another use of the database, I cannot get the new changed data without reloading the complete programme. Even repeating the load functions does not renew the data from the access data base.

Here is what I have got:

Public Class Form1
    Private comm As New CommManager()
    Private transType As String = String.Empty

    Dim inc As Integer
    Dim con As New OleDb.OleDbConnection
    Dim dbProvider As String
    Dim dbSource As String
    Dim laptimes As New DataSet

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


        dbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
        dbSource = "Data Source = f:/HareHound riderinput local.mdb;"

        con.ConnectionString = dbProvider & dbSource

        con.Open()
        sql = "SELECT * FROM laptimes"

        da = New OleDb.OleDbDataAdapter(sql, con)
        da.Fill(laptimes, "HareHounds")

        con.Close()

    End Sub
Private Sub btnimportdata_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnimportdata.Click
                CheckBox1.Checked = laptimes.Tables("HareHounds").Rows(0).Item(10)
    End Sub

I have tried everthing to get this very simple thing to work, but I am at a loss. Help would be largly apreciated.

riam.khalid.3 commented: how toget start with data base +0