General Database questions

General Database questions

Post by Bernie O'Brie » Mon, 29 Jun 1998 04:00:00

A couple of questions:
I apologize for the long post. Any suggestions would be appreciated.

Thanks in advance,


My first question is:
Why do I get multiple InputBoxes if I Loop through a procedure more than
once? For example, I put up an InputBox to allow the User to enter a value
to be included in a select statement. If they enter nothing, I capture that
and give them the opportunity to try again. If they accept the offer to try
again, the procedure will loop and create another instance of the InputBox.
I've tried to Unload it after each loop, but the syntax is all wrong. Here's
my code:

Private Sub DataSelect()
    Dim intAnswer As Integer
    Message = "Enter a Part Number"   ' Set message prompt.
    Title = "Part Number" ' Set title.
    Default = ""   ' Set default.
    strSelect = InputBox(Message, Title, Default)
    datData.RecordSource = "Select * FROM Parts WHERE PartNum Like '" & _
                           "*" & strSelect & "*" & "' ORDER BY PartNum"
    lblCount.Caption = ""
    Call RecordCountSelect
    Do While strSelect = "" Or txtPartNum = ""
        If MsgBox("You entered an incomplete or invalid Part Number:  " _
                  & strSelect & vbCrLf & "Do you want to try again?", _
                  vbYesNo, "PartNumber?") = vbNo Then
            datData.RecordSource = "Select * FROM Parts ORDER BY PartNum"
            Exit Do
            Exit Sub
            Call DataSelect
        End If
End Sub

My second question is as follows:
If I attempt to "Save" a duplicate value in the PartNum field I get the
usual error message (this is normal). However, if I attempt to refresh (e.g.
datData.Refresh) in any procedure directly after trying to save, I get a
runtime error #444 "Method not applicable in this context". Note that I can
"Refresh" at all other times. Here's the code for the "Save" procedure.
Below that is the code for the Refresh.:

Private Sub DataSave()
    If Len(txtPartNum.Text) > 0 Then
        On Error GoTo DuplicateError
        cmdData(1).Enabled = False
        cmdData(0).Caption = "&Add Record"
        Call RecordCountX   ' This call counts the records in the resultset
        datData.Recordset.Bookmark = datData.Recordset.LastModified
        Call ModeView   ' This call sets the controls on the form

        Exit Sub
    End If
    MsgBox "You have entered a duplicate Part Number.", _
           vbOKOnly, "Duplicate part Number!"
    Call ModeView   ' This call sets the controls on the form
End Sub

Private Sub DataRefresh()
    datData.RecordSource = "Select * from Parts ORDER BY PartNum"
    Call ModeView   ' This call sets the controls on the form
    Call RecordCountX   ' This call counts the records in the resultset
End Sub


1. General Database Question

        I have the need to query a database from a C program.  I'm looking
for input as to the best (or group of best), database packages for the job.
I'm in the process of writing a knowledge based system and would like to
use the database to gather and store the individual bits of information.
I figure that since that's what they do best, why bother doing it on my own.

        I'd like to find a package that will allow me to make sql (or sql-like)
calls right from C and have it work with the database package.

        This would be for a PC based system.  

        Any help would be appreciated.

        Please e-mail the information (post it too, if you care too... :-)

        Mitchel Ludwig

2. novell: file AND database server

3. newbie has general database question

4. ?? Tutorial Book On SyBase ??

5. general database question

6. Text file Search

7. Read Tables on CD-ROM [PW]

8. A general database question!

9. General database question, please.

10. General Database Questions...

11. General database questions for the expert

12. General Database Question