Blasshole
Jun 19th, 1999, 11:34 AM
I am trying to make a database with the dbgrid control. So far, I have added 10 columns and set the columns's names and captions. But how do you add rows to the grid by code? The code I have so far goes as follows:
The following is inserted into the general section of a module.
'toy stands for time of year(date screws things up)
Public RXNUMBER, TOY, ROOM, PNAME, DIRECT, DRUGNAME, STRENGTH, _
AMOUNT, DOCTOR, OTHERDIR As Column
The following is a funtion that will set up the columns and rows of the dbgrid.
Function SetUpData()
'add columns
Dim x As Integer
x = 1
Do
Form1.DBGrid1.Columns.Add 0
x = x + 1
Loop Until x = 10
Set RXNUMBER = Form1.DBGrid1.Columns(1)
Set TOY = Form1.DBGrid1.Columns(2)
Set ROOM = Form1.DBGrid1.Columns(3)
Set PNAME = Form1.DBGrid1.Columns(4)
Set DIRECT = Form1.DBGrid1.Columns(5)
Set DRUGNAME = Form1.DBGrid1.Columns(6)
Set STRENGTH = Form1.DBGrid1.Columns(7)
Set AMOUNT = Form1.DBGrid1.Columns(8)
Set DOCTOR = Form1.DBGrid1.Columns(9)
Set OTHERDIR = Form1.DBGrid1.Columns(10)
RXNUMBER.Visible = True
TOY.Visible = True
ROOM.Visible = True
PNAME.Visible = True
DIRECT.Visible = True
DRUGNAME.Visible = True
STRENGTH.Visible = True
AMOUNT.Visible = True
DOCTOR.Visible = True
OTHERDIR.Visible = True
RXNUMBER.Caption = "Rx Number"
TOY.Caption = "Date"
ROOM.Caption = "Room #"
PNAME.Caption = "Patient Name"
DIRECT.Caption = "Directions"
DRUGNAME.Caption = "Drug Name"
STRENGTH.Caption = "Strength"
AMOUNT.Caption = "Amount"
DOCTOR.Caption = "Doctor"
OTHERDIR.Caption = "Other Directions"
RXNUMBER.Width = 900
TOY.Width = 800
ROOM.Width = 800
DIRECT.Width = 2000
DRUGNAME.Width = 1100
STRENGTH.Width = 800
AMOUNT.Width = 800
DOCTOR.Width = 1000
OTHERDIR.Width = 1900
End Function
This funtion works to set up the columns of the grid, but how do you insert rows by code?
ANY HELP WOULD BE GREATLY APPRECIATED.
The following is inserted into the general section of a module.
'toy stands for time of year(date screws things up)
Public RXNUMBER, TOY, ROOM, PNAME, DIRECT, DRUGNAME, STRENGTH, _
AMOUNT, DOCTOR, OTHERDIR As Column
The following is a funtion that will set up the columns and rows of the dbgrid.
Function SetUpData()
'add columns
Dim x As Integer
x = 1
Do
Form1.DBGrid1.Columns.Add 0
x = x + 1
Loop Until x = 10
Set RXNUMBER = Form1.DBGrid1.Columns(1)
Set TOY = Form1.DBGrid1.Columns(2)
Set ROOM = Form1.DBGrid1.Columns(3)
Set PNAME = Form1.DBGrid1.Columns(4)
Set DIRECT = Form1.DBGrid1.Columns(5)
Set DRUGNAME = Form1.DBGrid1.Columns(6)
Set STRENGTH = Form1.DBGrid1.Columns(7)
Set AMOUNT = Form1.DBGrid1.Columns(8)
Set DOCTOR = Form1.DBGrid1.Columns(9)
Set OTHERDIR = Form1.DBGrid1.Columns(10)
RXNUMBER.Visible = True
TOY.Visible = True
ROOM.Visible = True
PNAME.Visible = True
DIRECT.Visible = True
DRUGNAME.Visible = True
STRENGTH.Visible = True
AMOUNT.Visible = True
DOCTOR.Visible = True
OTHERDIR.Visible = True
RXNUMBER.Caption = "Rx Number"
TOY.Caption = "Date"
ROOM.Caption = "Room #"
PNAME.Caption = "Patient Name"
DIRECT.Caption = "Directions"
DRUGNAME.Caption = "Drug Name"
STRENGTH.Caption = "Strength"
AMOUNT.Caption = "Amount"
DOCTOR.Caption = "Doctor"
OTHERDIR.Caption = "Other Directions"
RXNUMBER.Width = 900
TOY.Width = 800
ROOM.Width = 800
DIRECT.Width = 2000
DRUGNAME.Width = 1100
STRENGTH.Width = 800
AMOUNT.Width = 800
DOCTOR.Width = 1000
OTHERDIR.Width = 1900
End Function
This funtion works to set up the columns of the grid, but how do you insert rows by code?
ANY HELP WOULD BE GREATLY APPRECIATED.