Form Help (Re-post)

L

Leanne

Hi, I have the following code in a form but do not know how to do the
following.

'copy the data to the database – this is the part I need to change.
When I copy the data to the database I want only the entry in CmbSiteList
updated with what is in the text box TxtDate.
IE when a user selects ‘Portsmouth’ the entry for Portsmouth on ‘Dates’ is
updated with data in TxtDate.

Column A contains the customers name (and this is growing)
Column B is for Invoice Date
Column C is for Visit Date

Please can someone help as the code I have so far I has been taken from
http://www.contextures.on.ca/xlUserForm01.html#SetUp and other sources and
has not been written by myself as I would not know how. I have included the
whole code for the form so that you can see exactly where I am at.

Private Sub SaveVisit_Click()
Dim iRow As Long
Dim ws As Worksheet
Dim foundCell As Range
Set ws = Worksheets("Dates")
With Worksheets(1).Range("A1:A65536")

Set foundCell = .Find(What:=CmbSiteList.Value, lookAt:=xlWhole, _
LookIn:=xlValues, SearchOrder:=xlRows, _
MatchCase:=True, MatchByte:=True)

If Not foundCell Is Nothing Then
foundCell.Offset(0, 2).Value = TxtDate.Value
End If
End With

'check all mandatory fields complete
If Trim(Me.TxtDate.Value) = "" Then
Me.TxtDate.SetFocus
MsgBox "Please enter a valid Date"
Exit Sub
End If
If Trim(Me.CmbSiteList.Value) = "" Then
Me.CmbSiteList.SetFocus
MsgBox "Please select a Site"
Exit Sub
End If

'copy the data to the database
ws.Cells(iRow, 1).Value = Me.CmbSiteList.Value
ws.Cells(iRow, 2).Value = Me.TxtDate.Value

'clear the data
Me.CmbSiteList.Value = ""
Me.TxtDate.Value = ""
Me.CmbSiteList.SetFocus
End Sub
Private Sub CloseVisit_Click()
Unload Me
End Sub

Private Sub UserForm_Initialize()
CmbSiteList.RowSource = "Dates!A2:A300"
End Sub
 
M

Mark Ivey

Leanne,

If you can send me a copy of your file, I will see what I can do to help
out...

My email is wmivey6311 AT hotmail DOT com


Mark Ivey
 
L

Leanne

Thanks Mike. I have sent it over.

Mark Ivey said:
Leanne,

If you can send me a copy of your file, I will see what I can do to help
out...

My email is wmivey6311 AT hotmail DOT com


Mark Ivey
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top