Doug Mutzig
Board Regular
- Joined
- Jan 1, 2019
- Messages
- 57
- Office Version
- 365
- Platform
- Windows
Good afternoon all,
I am just starting with userforms and have run into some roadblocks. I have a userform, table on a data tab, and then a replicated form on another tab. The end user will use the form to enter data that is stored in the table and then the cells of the table are linked to the replicated form. I have a macro button to open the form, a button for a new record with some standard/default info, a button to save the data, and a close form button. The roadblocks I have are:
1. How do I get the userform to display the first row of data when opening?
2. How to I setup buttons for next and previous?
3. Since I am using linked cells deleting the table row causes issues, is there a way to set a button to just delete the data in the cells and then perform a sort on the table based on the first column (room)?
4. I also have a list box that shows the current room numbers, is there a way to double click on a room and show it's data in the form?
Data Table (T_Data)
Userform (Patient Data Entry Form)
Replicated form (the top area is for entering other information with the bottom set in a format the staff is used to viewing
My current code:
Any help you guidance you can provide would be greatly appreciated!
Doug
I am just starting with userforms and have run into some roadblocks. I have a userform, table on a data tab, and then a replicated form on another tab. The end user will use the form to enter data that is stored in the table and then the cells of the table are linked to the replicated form. I have a macro button to open the form, a button for a new record with some standard/default info, a button to save the data, and a close form button. The roadblocks I have are:
1. How do I get the userform to display the first row of data when opening?
2. How to I setup buttons for next and previous?
3. Since I am using linked cells deleting the table row causes issues, is there a way to set a button to just delete the data in the cells and then perform a sort on the table based on the first column (room)?
4. I also have a list box that shows the current room numbers, is there a way to double click on a room and show it's data in the form?
Data Table (T_Data)
Userform (Patient Data Entry Form)
Replicated form (the top area is for entering other information with the bottom set in a format the staff is used to viewing
My current code:
VBA Code:
Option Explicit
Dim nCurrentRow As Long
Dim ws As Worksheet
Dim FBR As Long 'FBR = First Blank Row
Private Sub ActiveRooms_Click()
Dim rng As Range
Set rng = Worksheets("Data").Range("A2:BD100")
If ActiveRooms.ListIndex <> -1 Then
End If
End Sub
Private Sub cmdSave_Click()
Set ws = Worksheets("Data")
With ws
'find first empty row in data worksheet
FBR = .Cells.Find(what:="*", LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row + 1
'copy the data to the data worksheet. Use protect and unprotect lines if worksheet is protected
' .Unprotect Password:="password"
.Cells(FBR, 1).Value = Me.RoomNumber.Value
.Cells(FBR, 2).Value = Me.TPMDue.Value
.Cells(FBR, 3).Value = Me.JOB.Value
.Cells(FBR, 4).Value = Me.FullName.Value
.Cells(FBR, 5).Value = Me.FMP.Value
.Cells(FBR, 6).Value = Me.Grade.Value
.Cells(FBR, 7).Value = Me.Sex.Value
.Cells(FBR, 8).Value = Me.Age.Value
.Cells(FBR, 9).Value = Me.Provider.Value
.Cells(FBR, 10).Value = Me.SocialWorker.Value
.Cells(FBR, 11).Value = Me.AdmitDate.Value
.Cells(FBR, 12).Value = Me.Unit.Value
.Cells(FBR, 13).Value = Me.TIS.Value
.Cells(FBR, 14).Value = Me.Dx.Value
.Cells(FBR, 15).Value = Me.Falls.Value
.Cells(FBR, 16).Value = Me.Status.Value
.Cells(FBR, 17).Value = Me.Allergies.Value
.Cells(FBR, 18).Value = Me.Med01_Name.Value
.Cells(FBR, 19).Value = Me.Med01_Dose.Value
.Cells(FBR, 20).Value = Me.Med01_Time.Value
.Cells(FBR, 21).Value = Me.Med02_Name.Value
.Cells(FBR, 22).Value = Me.Med02_Dose.Value
.Cells(FBR, 23).Value = Me.Med02_Time.Value
.Cells(FBR, 24).Value = Me.Med03_Name.Value
.Cells(FBR, 25).Value = Me.Med03_Dose.Value
.Cells(FBR, 26).Value = Me.Med03_Time.Value
.Cells(FBR, 27).Value = Me.Med04_name.Value
.Cells(FBR, 28).Value = Me.Med04_Dose.Value
.Cells(FBR, 29).Value = Me.Med04_Time.Value
.Cells(FBR, 30).Value = Me.Med05_name.Value
.Cells(FBR, 31).Value = Me.Med05_Dose.Value
.Cells(FBR, 32).Value = Me.Med05_Time.Value
.Cells(FBR, 33).Value = Me.Med06_Name.Value
.Cells(FBR, 34).Value = Me.Med06_Dose.Value
.Cells(FBR, 35).Value = Me.Med06_Time.Value
.Cells(FBR, 36).Value = Me.Med07_Name.Value
.Cells(FBR, 37).Value = Me.Med07_Dose.Value
.Cells(FBR, 38).Value = Me.Med07_Time.Value
.Cells(FBR, 39).Value = Me.Med08_Name.Value
.Cells(FBR, 40).Value = Me.Med08_Dose.Value
.Cells(FBR, 41).Value = Me.Med08_Time.Value
.Cells(FBR, 42).Value = Me.Med09_name.Value
.Cells(FBR, 43).Value = Me.Med09_Dose.Value
.Cells(FBR, 44).Value = Me.Med09_Time.Value
.Cells(FBR, 45).Value = Me.Med10_Name.Value
.Cells(FBR, 46).Value = Me.Med10_Dose.Value
.Cells(FBR, 47).Value = Me.Med10_Time.Value
.Cells(FBR, 48).Value = Me.DoDSER.Value
.Cells(FBR, 49).Value = Me.Branch.Value
.Cells(FBR, 50).Value = Me.SpecialNotes.Value
.Cells(FBR, 51).Value = Me.MissingItems.Value
.Cells(FBR, 52).Value = Me.AdmitNotes.Value
.Cells(FBR, 53).Value = Me.PsychHx.Value
.Cells(FBR, 54).Value = Me.MedHx.Value
.Cells(FBR, 55).Value = Me.PrevShift.Value
.Cells(FBR, 56).Value = Me.EstDischarge.Value
' .Protect Password:="password"
End With
cmdNew_Click
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub cmdNew_Click()
With Me
.RoomNumber.ListIndex = 0
.TPMDue.Value = ""
.JOB.Value = ""
.FullName.Value = ""
.FMP.Value = ""
.Grade.ListIndex = 0
.Sex.ListIndex = 0
.Age.Value = ""
.Provider.ListIndex = 0
.SocialWorker.ListIndex = 0
.AdmitDate.Value = ""
.Unit.Value = ""
.TIS.Value = ""
.Dx.Value = ""
.Falls.ListIndex = 0
.Status.ListIndex = 0
.Allergies.Text = "NKDA"
.Med01_Name.Text = "Tylenol"
.Med01_Dose.Text = "650mg"
.Med01_Time.Text = "Q6 PRN"
.Med02_Name.Text = "Maalox"
.Med02_Dose.Text = "30ml"
.Med02_Time.Text = "Q3 PRN"
.Med03_Name.Text = "Milk of Magnesia (MoM)"
.Med03_Dose.Text = "30ml"
.Med03_Time.Text = "Q6 PRN"
.Med04_name.Text = "Nicotine Gum"
.Med04_Dose.Text = "2mg"
.Med04_Time.Text = "Q2 Prn"
.Med05_name.Text = "Hydroxyzine"
.Med05_Dose.Text = "50mg"
.Med05_Time.Text = "QHS PRN"
.Med06_Name.Value = ""
.Med06_Dose.Value = ""
.Med06_Time.Value = ""
.Med07_Name.Value = ""
.Med07_Dose.Value = ""
.Med07_Time.Value = ""
.Med08_Name.Value = ""
.Med08_Dose.Value = ""
.Med08_Time.Value = ""
.Med09_name.Value = ""
.Med09_Dose.Value = ""
.Med09_Time.Value = ""
.Med10_Name.Value = ""
.Med10_Dose.Value = ""
.Med10_Time.Value = ""
.DoDSER.ListIndex = 0
.Branch.ListIndex = 0
.SpecialNotes.Value = ""
.MissingItems.Value = ""
.AdmitNotes.Value = ""
.PsychHx.Value = ""
.MedHx.Value = ""
.PrevShift.Value = ""
.EstDischarge.Value = ""
End With
End Sub
Private Sub UserForm_Click()
End Sub
Any help you guidance you can provide would be greatly appreciated!
Doug