[RESOLVED] how do display the last customers entry
hello everyone
i have a database with customers that i add each day
im trying to figure out how to see the new entries that i add in the same day
how many customers i added in the same day
like a report or something like that
i need a idea where to start this
regards salsa
Re: how do display the last customers entry
It would be easy if you have a timestamp field
Re: how do display the last customers entry
Re: how do display the last customers entry
Salsa
I think that Jggtz is suggesting that you add a field to your database
Then, each time a new record is added, also populate said field with the date it was added.
Subsequently, you could create an SQL statement to select only those records that match,
say, today's date.
Spoo
Re: how do display the last customers entry
this is the save button when i add the customer to the listview and save him in the DB
Code:
Private Sub SaveCust()
If Len(Trim$(Txt(1).Text)) = 0 Then
MsgBox "name cant be empty", vbExclamation, " "
Txt(1).SetFocus
Exit Sub
Else
Set RS = CN.Execute("SELECT * FROM Customers WHERE FullName='" & RplS(Txt(1).Text) & "'")
If Not RS.EOF Then
MsgBox "ì÷åç æä ëáø ÷ééí áîòøëú", vbExclamation, RS!FullName
Txt(1).SetFocus
Exit Sub
End If
End If
If Len(Trim$(Txt(2).Text)) = 0 Then
MsgBox "this customer already in the database", vbExclamation, "ùãåú çåáä"
Txt(2).SetFocus
Exit Sub
End If
If Len(Trim$(Txt(5).Text)) = 0 Then
MsgBox "fields missing", vbExclamation
Txt(5).SetFocus
Exit Sub
End If
If Len(Trim$(Txt(7).Text)) = 0 Then
MsgBox "fields missing", vbExclamation
Txt(7).SetFocus
Exit Sub
End If
If BttnPhoto.Picture = 0 Then
MsgBox "fields missing", vbInformation
Exit Sub
End If
Dim NewID As Long
NewID = NextID("ID", "Customers")
CN.Execute "INSERT INTO Customers (ID, FullName, Address, DateBirth, Facebook, Email, Phone, Cellular, HairColour, Oxygen, Photo) VALUES (" & _
NewID & ", '" & _
RplS(Txt(1).Text) & "', '" & _
RplS(Txt(2).Text) & "', #" & _
MyDate(PckBirth.Value) & "#, '" & _
RplS(Txt(4).Text) & "', '" & _
RplS(Txt(5).Text) & "', '" & _
RplS(Txt(6).Text) & "', '" & _
RplS(Txt(7).Text) & "', '" & _
RplS(Txt(8).Text) & "', '" & _
CmbOxygen.Text & "', '" & _
CmmDlg.FileName & "')"
Set Itm = LsVw.ListItems.Add(, , Txt(1).Text, , "cust")
Itm.Tag = NewID
Itm.Bold = True
Itm.SubItems(1) = Txt(2).Text
Itm.SubItems(2) = Format(PckBirth.Value, "dd/mm/yyyy")
Itm.SubItems(3) = Txt(4).Text
Itm.SubItems(4) = Txt(5).Text
Itm.SubItems(5) = Txt(6).Text
Itm.SubItems(6) = Txt(7).Text
Itm.SubItems(7) = Txt(8).Text
Itm.SubItems(8) = CmbOxygen.Text
Set BttnPhoto.Picture = LoadPicture(CmmDlg.FileName)
Itm.EnsureVisible
Itm.Selected = True
StBar.Panels(2) = Format(LsVw.ListItems.Count, "#,###0")
If ChkRepeat.Value Then
ClearDetails
Txt(1).SetFocus
Set BttnPhoto.Picture = Nothing
Exit Sub
End If
TmrClose.Enabled = True
Re: how do display the last customers entry
i never done this before a little help will be nice
hey spoo i need this to be saved in a clean DB
Re: how do display the last customers entry
Re: how do display the last customers entry
salsa31....
simply add a field in your DB (as suggested earlier), then, in your insert command, include that field and insert today's DATE (just like you did the DOB insert).
Then, to see who was ADDED on any given day, simply do a select statement. (You could use a datepicker control for the user to select any given date) If return is zero, don't do anything, but if greater than zero, display the info in a listbox (for example). Seems you have the knowledge of using the db okay, so you should have no problem doing this. If you do, post your attempt to 1, add the date to the db, and 2, retrieving by date.
Re: how do display the last customers entry