form to edit database

bademployee

Board Regular
Joined
Aug 19, 2010
Messages
184
Hi all

I have a form with 2 buttons to add new customers to our database;

PHP:
Private Sub cmdexit_Click()
  Unload Me
End Sub


Private Sub cmdsubmit_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Customer")

'find first empty row in database
iRow = ws.Cells(Rows.Count, 12) _
  .End(xlUp).Offset(1, 0).Row

'copy the data to the database
ws.Cells(iRow, 3).Value = Me.postal1.Value
ws.Cells(iRow, 4).Value = Me.postal2.Value
ws.Cells(iRow, 5).Value = Me.txtstate.Value
ws.Cells(iRow, 6).Value = Me.postcode.Value
ws.Cells(iRow, 7).Value = Me.txtemail.Value
ws.Cells(iRow, 8).Value = Me.txtphone.Value
ws.Cells(iRow, 9).Value = Me.txtfax.Value
ws.Cells(iRow, 10).Value = Me.tradingname.Value
ws.Cells(iRow, 11).Value = Me.txtabn.Value
ws.Cells(iRow, 12).Value = Me.txtmobile.Value
ws.Cells(iRow, 13).Value = Me.contactname.Value

'clear the data
Me.postal1.Value = ""
Me.postal2.Value = ""
Me.txtstate.Value = ""
Me.postcode.Value = ""
Me.txtemail.Value = ""
Me.txtphone.Value = ""
Me.txtfax.Value = ""
Me.contactname.Value = ""
Me.txtabn.Value = ""
Me.txtmobile.Value = ""
Me.tradingname.Value = ""
Me.postal1.SetFocus

  Unload Me
End Sub
The existing customers are selected by using a combo box linked to cell C9. I would like to be able to edit existing customer details by opening up the same sort of form, retrieving the customer details based on value in C9.

Any help would be appreciated.

Mark
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Forum statistics

Threads
1,224,609
Messages
6,179,874
Members
452,949
Latest member
Dupuhini

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top