|
-
May 17th, 2007, 01:54 PM
#1
Thread Starter
Fanatic Member
Unknown bug in program, please assist.
There's a problem that seems to lie in when my recordset puts my data inside the database, because when I type it in, it's fine, but when it gets to the database, it's like someone held the spacebar down for a couple of seconds, and data that would otherwise fit snugly inside the fields gives me an error saying that the data stream is too large (apparently because of the added spaces.)
This is the relevant code. I can add more details if needed.
Code:
Dim WkSpc As DAO.Workspace
Dim db As Database
Dim RecordSource As String
Dim TableName As String
Set rs = New Recordset
On Error GoTo ErrorHandler
Select Case Index
Case 0
If MasterControl.Text = "" Then
MsgBox "You must specify a header in which to put the data.", vbInformation, App.Title
Exit Sub
End If
RecordSource = "SELECT * FROM " & MasterControl.Text & " ORDER BY SiteName"
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Databases\" & MasterControl.Text & ".mdb;Persist Security Info=False"
rs.Open RecordSource, ConnectionString, adOpenKeyset, adLockOptimistic
If rs.BOF = False Then
rs.MoveFirst
End If
For i = 1 To rs.RecordCount
If Data(0).Text = rs!SiteName Then
MsgBox "Duplicate records are not allowed", vbInformation, "Record already exists"
Exit Sub
Else
rs.MoveNext
End If
Next i
rs.AddNew
rs!SiteName = Data(0).Text
rs!SiteURL = Data(1).Text
rs!EMail = Data(2).Text
rs!Category = Data(3).Text
rs!Username = Data(4).Text
rs!Password = Data(5).Text
rs.Update
rs.Close
Set rs = Nothing
OrganizerDatabase.ListItems.Add , , Data(0).Text
Basically, when the function starts, it checks a combobox and an array of textboxes to see if any are empty. It then checks the text in the first textbox against each record in the database for duplicate data. If duplicate data is found, it will display a messagebox and end all processing, otherwise it will continue adding the record.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|