Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

dao recordset not updated

11 views
Skip to first unread message

Jerry Nettleton

unread,
Aug 28, 2008, 5:50:00 PM8/28/08
to
I am trying to update a legacy VB6 program to open an Access 2003 database.
The problem that I have is that the DBCombo controls are not updating the
Recordset when a new record is created. Please take a look at my sample
project to see if I'm missing anything obvious:

VERSION 5.00
Object = "{FAEEE763-117E-101B-8933-08002B2F4F5A}#1.1#0"; "DBLIST32.OCX"
Begin VB.Form Form1
Caption = "MainCar"
ClientHeight = 4440
ClientLeft = 60
ClientTop = 450
ClientWidth = 4185
LinkTopic = "Form1"
ScaleHeight = 4440
ScaleWidth = 4185
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton cmdSave
Caption = "SAVE"
Enabled = 0 'False
Height = 495
Left = 1920
TabIndex = 4
Top = 3000
Width = 1215
End
Begin VB.CommandButton cmdNew
Caption = "NEW"
Height = 495
Left = 480
TabIndex = 3
Top = 3000
Width = 1215
End
Begin VB.Data datMainCar
Caption = "Data1"
Connect = "Access 2000;"
DatabaseName = "C:\DATA2003\data.mdb"
DefaultCursorType= 0 'DefaultCursor
DefaultType = 2 'UseODBC -- Properties show "2 - Use Jet"
Exclusive = 0 'False
Height = 345
Left = 480
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = "MainCar"
Top = 3720
Width = 2415
End
Begin MSDBCtls.DBCombo dbcCarIdNo
Bindings = "Form1.frx":0000
DataField = "CarIdNo"
DataSource = "datMainCar"
Height = 315
Left = 1320
TabIndex = 5
Top = 240
Width = 1455
_ExtentX = 2566
_ExtentY = 556
_Version = 393216
ListField = "CarIdNo"
BoundColumn = "CarIdNo"
Text = ""
End
Begin MSDBCtls.DBCombo dbcStatus
Bindings = "Form1.frx":0035
DataField = "Status"
DataSource = "datMainCar"
Height = 315
Left = 1320
TabIndex = 6
Top = 840
Width = 1455
_ExtentX = 2566
_ExtentY = 556
_Version = 393216
Text = ""
End
Begin MSDBCtls.DBCombo dbcTransType
Bindings = "Form1.frx":0060
DataField = "TransactionType"
DataSource = "datMainCar"
Height = 315
Left = 1320
TabIndex = 7
Top = 1440
Width = 1455
_ExtentX = 2566
_ExtentY = 556
_Version = 393216
Text = ""
End
Begin VB.Label lblTransType
Caption = "Trans Type"
Height = 375
Left = 240
TabIndex = 0
Top = 1440
Width = 975
End
Begin VB.Label lblCarId
Caption = "Car ID"
Height = 375
Left = 240
TabIndex = 2
Top = 240
Width = 975
End
Begin VB.Label lblStatus
Caption = "Status"
Height = 375
Left = 240
TabIndex = 1
Top = 840
Width = 975
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub form1_load()
datMainCar.Refresh
End Sub

Private Sub cmdNew_Click()
datMainCar.Refresh
datMainCar.Recordset.AddNew
'datMainCar.UpdateControls

cmdSave.Enabled = True
cmdNew.Enabled = False
End Sub

Private Sub cmdSave_Click()
Dim str As String
str = ""
With datMainCar.Recordset
If .EditMode = dbEditAdd Then
cmdSave.Enabled = False
cmdNew.Enabled = True

'datMainCar.UpdateControls

If dbcCarIdNo.Text = !CarIdNo Then
str = str & !CarIdNo
End If
If dbcStatus.Text = !Status Then
str = str & !Status
End If
If dbcTransType.Text = !TransactionType Then
str = str & !TransactionType
End If
If str = "" Then
MsgBox "RECORDSET NOT UPDATED"
End If

.CancelUpdate
End If
End With
End Sub

0 new messages