Hi
I have a form in vb.net that contains textbox as ID, Name, Age, Sex, Hb, BG.
in database access i have 2 tables as Table1 and Table2.
The Table1 contains ID,Name,Age,Sex and Hb.
The Table2 contains ID,Name,Age,Sex and BG.
I want to save data as ID,Name,Age,Sex, BG to table2 only when i enter any value into textbox "BG" along with other textbox values.
Otherwise it will be saved in Table1 as ID,Name,Age,Sex,Hb when i enter Hb value alon with other textbox values.
And when i enter both Hb and BG value, both tables will save respective data.
So please help me with code.

I don't know your data, but you should probably use 3 tables:

Table 1:

  • ID: primary key
  • Name
  • Age
  • Sex

If one ID in Table 1 has many entries in Table 2:

Table 2:
1:M (1 to many)

  • ID: primary key, foreign key references Table1(ID)
  • Hb: primary key

If one ID in Table 1 has, at most, one entry in Table 2:

Table 2:
1:1 (1 to 1)

  • ID: primary key, foreign key references Table1(ID)
  • Hb:

If one ID in Table 1 has many entries in Table 3:

Table 3:
1:M (1 to many)

  • ID: primary key, foreign key references Table1(ID)
  • BG: primary key

If one ID in Table 1 has, at most, one entry in Table 3:

Table 3:
1:1 (1 to 1)

  • ID: primary key, foreign key references Table1(ID)
  • BG:

Of course, you have to look at your data, and then choose your table design appropriately. If you are duplicating a bunch of columns, you probably need another table.

Edited 2 Years Ago by cgeier

We don't write your code for you. If you want to hire someone to write your code for you, there are other sites for that.

This article has been dead for over six months. Start a new discussion instead.