•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Database Design section within the Web Development category of DaniWeb, a massive community of 360,994 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,536 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Database Design advertiser:
Views: 2387 | Replies: 2
![]() |
•
•
Join Date: Dec 2005
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
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...
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
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
•
•
Join Date: Dec 2005
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
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
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
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Database Design Marketplace
- Database question (Visual Basic 4 / 5 / 6)
- radio button ASP question?? (ASP)
- database question (C#)
- Database Question From Newbie (MySQL)
Other Threads in the Database Design Forum
- Previous Thread: Opening Outlook Template in Access
- Next Thread: Simple sql questions (broken commands and retrieving columns)


Linear Mode