943,983 Members | Top Members by Rank

Ad:
Dec 2nd, 2005
0

Database question.. Can someone help...

Expand Post »
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...
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
droopy420 is offline Offline
3 posts
since Dec 2005
Dec 7th, 2005
0

Re: Database question.. Can someone help...

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
Reputation Points: 10
Solved Threads: 0
Light Poster
noman78 is offline Offline
40 posts
since Nov 2005
Dec 12th, 2005
0

Re: Database question.. Can someone help...

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
droopy420 is offline Offline
3 posts
since Dec 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Database Design Forum Timeline: Opening Outlook Template in Access
Next Thread in Database Design Forum Timeline: Simple sql questions (broken commands and retrieving columns)





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC