View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
M.Desmond M.Desmond is offline
external usenet poster
 
Posts: 11
Default multiple updates to database

Hi Mike-First Thank you.

Let me answer those Qs:
#1:Once the cow gets a certain vaccination say in column C then her next
would be recorded in Column D. None of them expire-so no dates would be
replaced ever. Once the cow gets all her vaccinations she is removed from the
database-so no replacement of cell data occurs.
#2:Specific vaccines go in specific columns yes. Each column is labeled with
the name of the vaccination. (Example-Column C="12 month Vacc.", Column
D="14Month Vacc.")
So yes they are specific that is why is has been a little difficult to have
multiple cows that could be getting different vaccinations be updates at
once. What I had set up is a status cell at the end of each row that updates
each cow's vaccination status depending upon how many cells within their row
is filled. (Example-If only cells through Column C are filled then that cow's
vaccination status would say "14Month" because that is the vacc she is due
for next. )

Its been an interesting program to work out. But basically if there is a way
to individually look at the selected cow's row and fill in their last empty
column with a date then their status is updated and this process does not
have to be done manually for each cow.

Again thank you for your help-let me know if I have answered your two
questions-I will give the code a go today!!

"Mike H." wrote:

A couple questions:
1. If cow #1 has nothing in column C and you vaccinate for "Col-C Vaccine",
then you store the date in Column C. But if there is a date in that column
but it was "expired", then do you record the "Col-C Vaccine" in column C,
this time wiping out the old date that you replaced.

2. Do you always record a specific vaccine's date in a a specific column?
That is what it at first sounded like, but then later in your text, it led me
to believe that was not necessarily the case.

Based on your answers to these questions, this code might change a bit, but
this is the idea I have for doing this:

Sub DoForm()
Dim TheDate As Date
Dim X As Long
Dim NbrVaccined As Integer '
Dim Y As Integer

UserForm1.Show

If UserForm1.datefield = True Then
Let TheDate = UserForm1.datefield
Else
Exit Sub
End If

'get your cow #'s etc. Let's assume you assigned them to an array:
CowList(5,2) where the
'first element is the Cow #, the second # is the vaccine Type. Now you have
all the parts:

'just go to the list and write the data out:

Range("CowList").Select
X = ActiveCell.Row
Do While True
If Cells(X, 1).Value = Empty Then Exit Do 'if there is no cow # in col
A, then you're done.
For Y = 1 To NbrVaccined
If Cells(X, 1).Value = cowlist(Y, 1) Then
If cowlist(Y, 2) = 1 Then '(or whatever you use to differentiate
the type of vaccine)
Cells(X, 2).Value = TheDate
ElseIf cowlist(Y, 2) = 2 Then
Cells(X, 3).Value = TheDate
'etc....
End If
End If
Next
Loop



End Sub

HTH!