LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default Error Adding to Spreadsheet Please help!!! Complex ?

On Nov 13, 11:19 am, wrote:
Using the "add" button to add information to a specified area, It
does Not add to the combobox
I am Still very new to vba and Not really sure what im doing wrong, i
want it to test if the textboxes are empty, if they arent they
should test to see if it already exists, if it does tell me it does
and not allow me to create it, if it doesnt it should create it, and
add the information to the sheet.

Private Sub CmdAdd_Click()
Dim strNewPerson As String
Dim NewName As String
Dim cnt As Long
Dim NewParent As String
NewName = TxtFirstName.text & "," & TxtLastName.text
If Len(CBOMoFa) = 0 Or Len(TxtFirstName) = 0 Or Len(TxtLastName) = 0 _
Or Len(TxtChild) = 0 Then
MsgBox " Please Insert Missing Information ",
vbOKOnly ' If they are empty dont allow them to do it

End If
For cnt = 0 To CBONames.ListCount - 1
If NewName = CBONames.List(cnt) Then
MsgBox " This Person Is Already on the List", vbOKOnly
If CBONames.ListCount = 0 Then ' Hoping i
used this correctly

' basically if there are no names left then

' this is the new string add it to the form
strNewPerson = TxtFirstName & "," & TxtLastName & "," &
CBOMoFa & "," & _
TxtChild & "," & TxtIssued & "," & TxtServed
NewParent = GetArea(strNewPerson)
End If
cnt = cnt + 1
End If
Next
End Sub

This Function Should Find where the information shoudl be put

Private Function GetArea(strname As String)
Dim StrNewfound As String
Dim I As Integer
Dim cnt As Integer
I = 0
ParentArray = Array("Mother:1", "Mother:2", "Mother:3", "Putative
Father", "Putative Father:2", "Putative Father:3", "Putative Father:
4", _
"Putative Father:5", "Putative Father:6", "Father:1", "Father:2",
"Father:3", "Father:4", "Father:5", "Father:6", "Father:7", "Father:
8")

Do
For cnt = 25 To 41
StrNewfound = SplitMe(strname, 2) ' split the
string
If StrNewfound < "" Then
If StrNewfound = ParentArray(I) Then ' test
to see if cbomofa and strnewfound are equal

Range("A5:AX4500").Find(TxtCaseName,
LookIn:=xlValues).Offset(0, cnt) = strname
CBONames.AddItem StrNewfound
GetArea = SplitMe(strname, 0)
End If
Else
MsgBox ParentArray(I) & " Already Exists"
End If
I = I + 1
cnt = cnt + 1
While ParentArray(I) <= 17

End Function

This is what im using to split the strings

Private Function SplitMe(strToSplit As String, intChoose As Integer)
As String
Dim vntX As Variant

vntX = Split(strToSplit, ",")

If intChoose = 0 Then
SplitMe = vntX(0) & "," & vntX(1) ' vntX(0) is
TxtFirstName
ElseIf intChoose = 2 Then ' vntX(1) is TxtLastName
SplitMe = vntX(2) ' vntX(2) is
cbomofa combobox mother father
ElseIf intChoose = 1 Then ' vntX(3) is Childs name
TxtFirstName = vntX(0) ' vntX(4) is date
issued
TxtLastName = vntX(1) ' vntX(5) is date served
TxtChild = vntX(3)
If UBound(vntX) = 4 Then
TxtIssued = vntX(4)
Else
TxtIssued = ""
End If
If UBound(vntX) = 5 Then
TxtServed = vntX(5)
Else
TxtServed = ""
End If
SplitMe = vntX(2)
End If
End Function


PLEASE HELP!!!

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Complex Question - XML Validation in Spreadsheet Web Component Perico[_2_] Excel Programming 0 August 31st 07 01:16 AM
Reverse Engineer complex spreadsheet davegb Excel Programming 5 May 7th 07 10:05 PM
How to run a complex SQL statement against Excel spreadsheet range? TCook Excel Programming 6 November 27th 06 01:02 AM
Ruby access to an existing Spreadsheet with complex formulae seabird20 Excel Discussion (Misc queries) 0 August 2nd 06 07:43 PM
Still adding to Complex Macro...1 step at a time. oberon.black[_6_] Excel Programming 1 September 4th 05 06:05 PM


All times are GMT +1. The time now is 06:54 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"