Hi, I’m an intermediate programmer but new to VB/VBA and rather unfamiliar with the VBA Object Model. I was tasked to build a "pusedo" vending machine program for a self-service concession stand. I am trying to sharpen my VBA skills instead of writing it in a language i already know. Here a summary of what I am attempting to accomplish.
1. User enters ID number and clicks Enter button
search column “A” on “Sheet2” for a matching id number
if match found, populate name to name text box, balance to balance text box, and purchase history to list-box
2. User can click on various price buttons
each button click value will be added to the total text box
3. User can add to balance or pay for purchase.
if add to balance is clicked, add the total to the balance
if pay is clicked, amount entered for payment will be subtracted from balance
4. all user form actions should be updated on sheet2
5. if cancel selected, clear form data and do not update spreadsheet
6. if done is selected, save document
i am lost on much of this project and any assistance would be appreciated. My project can be found here: https://www.dropbox.com/s/zhubys0z0w7z4t3/concession.xlsm
here is my current code that looks for the the id number match
Private Sub identer_btn_Click()
On Error GoTo errorhandler
Application.ScreenUpdating = False
Range("A1:A50").Select
Selection.Find(What:=Consession.id_txt.Text, After:=ActiveCell, LookIn:=xlValues, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False).Activate
Unload Consession
ActiveCell.Offset(1, 0)
Cells(1, 1).Select
Exit Sub
errorhandler:
MsgBox "ID Not on Team Roster! You must pay for your items now!" & vbOKOnly
Consession.id_txt.SetFocus
End Sub
1. User enters ID number and clicks Enter button
search column “A” on “Sheet2” for a matching id number
if match found, populate name to name text box, balance to balance text box, and purchase history to list-box
2. User can click on various price buttons
each button click value will be added to the total text box
3. User can add to balance or pay for purchase.
if add to balance is clicked, add the total to the balance
if pay is clicked, amount entered for payment will be subtracted from balance
4. all user form actions should be updated on sheet2
5. if cancel selected, clear form data and do not update spreadsheet
6. if done is selected, save document
i am lost on much of this project and any assistance would be appreciated. My project can be found here: https://www.dropbox.com/s/zhubys0z0w7z4t3/concession.xlsm
here is my current code that looks for the the id number match
Private Sub identer_btn_Click()
On Error GoTo errorhandler
Application.ScreenUpdating = False
Range("A1:A50").Select
Selection.Find(What:=Consession.id_txt.Text, After:=ActiveCell, LookIn:=xlValues, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False).Activate
Unload Consession
ActiveCell.Offset(1, 0)
Cells(1, 1).Select
Exit Sub
errorhandler:
MsgBox "ID Not on Team Roster! You must pay for your items now!" & vbOKOnly
Consession.id_txt.SetFocus
End Sub