4 Replies - 1396 Views - Last Post: 12 December 2013 - 06:27 AM Rate Topic: -----

#1 143Dongwoon  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 08-December 13

Expiration date in vb6

Posted 11 December 2013 - 09:43 PM

Can someone help me I'm having some problem with this. I am supposed to make a system that will alert if the medicine was expired. I am using vb 6 and access for my database. thank you


here is my code.

Private Sub DataGrid1_Click()
On Error Resume Next
Command2.Enabled = True
With frmmed1
    .Combo1 = Adodc1.Recordset.Fields("MedicineName")
    .Text3.Text = Adodc1.Recordset.Fields("StockQuantity")
    .Combo2 = Adodc1.Recordset.Fields("Expmonth")
    .Combo3 = Adodc1.Recordset.Fields("Expday")
    .Combo4 = Adodc1.Recordset.Fields("Expyear")
End With


Dim currentdate As Date
Dim expirationdate
currentdate = DateValue(Now)
expirationdate = Combo2 & Combo3 & Combo4

Text6.Text = currentdate

If Text6.Text > expirationdate Then (-----I'm having trouble with this line)
    MsgBox "OK! =)", , "Working"
     Text2.Enabled = True
    
Else
    MsgBox "Medicine Expired! Click OK to delete.", vbExclamation, "   Warning!!!"
Text2.Enabled = False

    If MsgBox("Are you want to delete " & Combo1 & "?", vbQuestion + vbYesNo, "Message") = vbYes Then
Adodc1.Recordset.Delete
ElseIf vbNo Then Exit Sub
End If
End If


End Sub



Is This A Good Question/Topic? 0
  • +

Replies To: Expiration date in vb6

#2 nikhilgup  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 08-November 13

Re: Expiration date in vb6

Posted 12 December 2013 - 12:23 AM

Hi,

You can try using vb's day, year and month functions instead of using text box and compare then with the combobox used for expiration date.

you can bread the date as follows:

Day(currentdate)
Year(currentdate)
Month(currentdate)



Now your date will be distributed in day, year and month and it will be easy to compare

Hope this helps!

Thanks,
Best Regards,
Nikhil Gupta

This post has been edited by andrewsw: 12 December 2013 - 12:29 AM
Reason for edit:: Removed previous quote

Was This Post Helpful? 0
  • +
  • -

#3 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 299
  • View blog
  • Posts: 1,768
  • Joined: 26-March 09

Re: Expiration date in vb6

Posted 12 December 2013 - 01:13 AM

Another alternative would be to store the expiration date as a date in the DB.

A function to look at that might life easier is DATEDIFF.

This post has been edited by maj3091: 12 December 2013 - 01:14 AM

Was This Post Helpful? 1
  • +
  • -

#4 143Dongwoon  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 08-December 13

Re: Expiration date in vb6

Posted 12 December 2013 - 03:07 AM

View Postnikhilgup, on 12 December 2013 - 12:23 AM, said:

Hi,

You can try using vb's day, year and month functions instead of using text box and compare then with the combobox used for expiration date.

you can bread the date as follows:

Day(currentdate)
Year(currentdate)
Month(currentdate)



Now your date will be distributed in day, year and month and it will be easy to compare

Hope this helps!

Thanks,
Best Regards,
Nikhil Gupta





[qoute]
thank you very much for your response..

but still it doesn't work. Do you think I need to put the name of the fields on database instead of Month, Day and Year?
thank you..

Dim currentDate As Date
Dim expirationDate
Month(currentDate) = Combo2
Day(currentDate) = Combo3
Year(currentDate) = Combo4

date.value = Format(Now, "MMM-DD-YYYY")



[/quote]
Was This Post Helpful? 0
  • +
  • -

#5 143Dongwoon  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 08-December 13

Re: Expiration date in vb6

Posted 12 December 2013 - 06:27 AM

View Post143Dongwoon, on 12 December 2013 - 03:07 AM, said:

View Postnikhilgup, on 12 December 2013 - 12:23 AM, said:

Hi,

You can try using vb's day, year and month functions instead of using text box and compare then with the combobox used for expiration date.

you can bread the date as follows:

Day(currentdate)
Year(currentdate)
Month(currentdate)



Now your date will be distributed in day, year and month and it will be easy to compare

Hope this helps!

Thanks,
Best Regards,
Nikhil Gupta





[qoute]
thank you very much for your response..

but still it doesn't work. Do you think I need to put the name of the fields on database instead of Month, Day and Year?
thank you..

Dim currentDate As Date
Dim expirationDate
Month(currentDate) = Combo2
Day(currentDate) = Combo3
Year(currentDate) = Combo4

date.value = Format(Now, "MMM-DD-YYYY")





I've already solved it thanks. this is really helpful :) Salamat..

View Postmaj3091, on 12 December 2013 - 01:13 AM, said:

Another alternative would be to store the expiration date as a date in the DB.

A function to look at that might life easier is DATEDIFF.


thanks :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1