Program- VB 6.0
Database- MS Access 2003

I'm build a database base on my household bills. And I have already the database connects to the program, but I am unable to get some of my functions to run correctly. These are the problems that I am having...

1. I am able to retrieve data from my "Household" database, but I can't add, delete, or update the database, without go in manually and doing so.

2. I can't retrieve data by date from my "Lookup" database.

And

3. I trying to write a code to were I am able to type in the date and the when my database retrieves it, ii will have the format (MM/dd/yyyy).

Thank in advance...

abt ur first two points, i need to see the code u r using, are u suing access forms to retrieve and save or its some other programming language
abt third point, the default dateformat for access is mm/dd/yyyy
so db alwasy save in this format, so for this u need to save by formatting it and need to retriever by formatting as well
format(fieldname,"dd/mm/yyyy") fro retival and
format(field,"mm/dd/yyyy") for save, if u r inputting in dd/mm/yyyy
these formats for visual basic
or u can change the regional settings -->date to dd/mm/yyyy as well

Here is what I have in code..
Hope this is helpful.


Option Explicit
Dim b_onAdd As Boolean


Dim ConStr As String
Dim Con As ADODB.Connection


Private Sub cmdAdd_Click()
b_onAdd = True
disableBtn
adoBillInfo.Recordset.AddNew
End Sub

Private Sub cmdCancel_Click()
If b_onAdd Then
b_onAdd = False
enableBtn
End If
adoBillInfo.Recordset.CancelUpdate
End Sub

Private Sub cmdDelete_Click()
Dim response As Integer
response = MsgBox("Are you sure want to delete this record?", vbOKCancel, "Delete record for" & txtCompanyName.Text)
If response = vbOK Then
adoBillInfo.Recordset.Delete
adoBillInfo.Recordset.MoveFirst
txtTotalRecords.Text = adoBillInfo.Recordset.RecordCount
End If
End Sub

Private Sub cmdUpdate_Click()
If b_onAdd Then
b_onAdd = False
enableBtn
End If
adoBillInfo.Recordset.Update
txtTotalRecords.Text = adoBillInfo.Recordset.RecordCount
End Sub

Private Sub dblBillInfo_Click()
adoBillInfo.Recordset.Bookmark = dblBillInfo.SelectedItem

End Sub

Private Sub Form_Load()
Dim StrCompanyName As String
Dim CurAmountDue As Currency
Dim CurAmountPaid As Currency
txtCompanyName.Text = StrCompanyName
'txtDateDue.Text =
'txtDatePaid.Text = dtDate
txtAmountDue.Text = CurAmountDue
txtAmountPaid.Text = CurAmountPaid

Dim CnnStr As String 'connection string
CnnStr = "Provider=Microsoft.Jet.OLEDB.4.0;User ID=admin;Data Source=C:\House.mdb;Persist Security Info=False"
'set properties for ADODC adoBillInfo
With adoBillInfo
.ConnectionString = CnnStr
.CommandType = adCmdTable 'display results from a table
.RecordSource = "House"
End With
'set properties for ADODC adoLookup
With adoLookup
.ConnectionString = CnnStr
.CommandType = adCmdTable 'display results from a table
.RecordSource = "Lookup"
'set properties for DataCombo control dbcLookup
With dbcLookup
Set .DataSource = adoBillInfo.Recordset
Set .RowSource = adoBillInfo.Recordset
.ListField = "DateDue"
.BoundColumn = "EntryID"
.DataField = "EntryID"
End With
ConStr = "Provider =Microsoft.Jet.OLEDB.4.0;" & "Data Source =C:\House.mdb"

Set Con = New ADODB.Connection 'establish a new connection
Con.ConnectionString = ConStr
'other lines of code
End With
b_onAdd = False
'txtTotalRecords.Text = House.Recordset.RecordCount
End Sub

Private Sub ConnectToDb()
ConStr = "DSN= BILLS;UID=admin;PWD=bloone"

Set Con = New ADODB.Connection 'establish a new connection
Con.ConnectionString = ConStr
'other lines of code
End Sub

Private Sub disableBtn()
cmdAdd.Enabled = False
cmdDelete.Enabled = False
End Sub

Private Sub enableBtn()
cmdAdd.Enabled = True
cmdDelete.Enabled = True
End Sub

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.