Form Code

Onicat

New Member
Joined
Feb 16, 2019
Messages
11
Good Day,
I have been working on this vb code based off some of your code, for building fillible forms. We are having an issue with the Private Sub SaveClient_Click Subroutine. The reason I changed the cell numbers, is to move them to the starting location on our workbook. as we want to have the data add a new row starting at C9, and just adding new clients as we get them.


Any help would be great.
Thanks - Lost Coder


Private Sub SaveClient_Click()
'Copy input values to sheet.
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
iRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
With ws
.Cells(9, 3).Value = Me.SDSID.Value
.Cells(9, 4).Value = Me.LastName.Value
.Cells(9, 5).Value = Me.FirstName.Value
.Cells(9, 6).Value = Me.Harmony.Value
.Cells(9, 7).Value = Me.StreetAddress.Value
.Cells(9, 8).Value = Me.City.Value
.Cells(9, 9).Value = Me.State.Value
.Cells(9, 10).Value = Me.Zip.Value
.Cells(9, 11).Value = Me.DOB.Value
.Cells(9, 12).Value = Me.Gender.Value
.Cells(9, 13).Value = Me.Mediciad.Value
.Cells(9, 14).Value = Me.BillingStatus.Value
End With



End Sub
 
In that case you're button is not called SaveClient, in the VB editor show the form & double click the button, it should take you to the code module with something like
Code:
Private Sub [COLOR=#0000ff]CommandButton1[/COLOR]_Click()

End Sub
where the part in blue is the name of your button.

Below I have attached a snipit of the area I believe you are talking about. I am starting to get the feeling a missed a simple step somewhere and it is driving me nuts. LOL

(Name) SaveClient


https://drive.google.com/file/d/14A8YRLTc1JBhuVTJ9RKR2nyTY2I1QQuC/view?usp=sharing
 
Upvote 0

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
That looks fine, is the code in the UserForm module?
 
Upvote 0
If you doubleclick the button in the editor, the code window should open up & the cursor should be in the Private Sub SaveClient_Click() sub.
Is it?
 
Upvote 0
In that case I have no idea what is happening.
Would you be willing to share the file, having removed a confidential info?
If so you would need to upload it to a share site such as OneDrive, DropBox, GoogleDrive, mark for sharing & post the link to the thread.
 
Upvote 0
In that case I have no idea what is happening.
Would you be willing to share the file, having removed a confidential info?
If so you would need to upload it to a share site such as OneDrive, DropBox, GoogleDrive, mark for sharing & post the link to the thread.

https://drive.google.com/file/d/19NkNm95K1Or0yYQukAbj_gfITBovlVdy/view?usp=sharing

Notes -
End Goal for this step in building this is to for Staff to be able to input data using a forum that will auto fill the workbook, adding a new line for each new data inputted.
There will be one worksheet for each staff, and the code repeated, unless there is a way to input the data based on the worksheet open, or if the a forum box could be filled with a drop down to fill the appropriate worksheet.
Everything after Column O is Data that will be used to auto populate other worksheets.
 
Last edited:
Upvote 0
Try
Code:
Private Sub SaveClient_Click()
   'Copy input values to sheet.
   With ActiveSheet
      .Rows(10).Insert
      .Cells(10, 3).Value = Me.SDSID.Value
      .Cells(10, 4).Value = Me.LastName.Value
      .Cells(10, 5).Value = Me.FirstName.Value
      .Cells(10, 6).Value = Me.Harmony.Value
      .Cells(10, 7).Value = Me.StreetAddress.Value
      .Cells(10, 8).Value = Me.City.Value
      .Cells(10, 9).Value = Me.State.Value
      .Cells(10, 10).Value = Me.Zip.Value
      .Cells(10, 11).Value = Me.DOB.Value
      .Cells(10, 12).Value = Me.Gender.Value
      .Cells(10, 13).Value = Me.Mediciad.Value
      .Cells(10, 14).Value = Me.BillingStatus.Value
   End With
End Sub
This will put the data on whichever is the activesheet.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,326
Members
452,635
Latest member
laura12345

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