Routine has been baffled - Forum

Forum Navigation
You need to log in to create posts and topics.

Routine has been baffled

InputBox "Check Member Number" "Look FOR Duplicates" "[FoundNumber]"
If "[FoundNumber]" ">" ""
  dbpQuery "ARMDB" "Members" "OSSTF = [#34][FoundNumber][#34]"
  If "[ARMDB.Members.$RecCount]" "=" "0"
    AlertBox "Ok" "No duplicates were found."
    dbpShowAll "ARMDB" "Members"
    dbpAddRecord "ARMDB" "Members"
    SetVar "[ARMDB.Members.OSSTF]" "[FoundNumber]"
    FocusObject "LASTNAME"

  Else
   AlertBox "Duplicate Number" "Member Number [FoundNumber] already exists."
   dbpShowAll "ARMDB" "Members"
   dbpSort "ARMDB" "Members" "LASTNAME=ASC;FIRSTNAME=ASC"
  EndIf
 
ELSE
  AlertBox "Search Number" "Member Number field is Blank.|Aborted !"
ENDIF

I use similar routine in another program without this problem.

This routine inserts a blank record in the database and well as allowing me to create record which I can edit / add to.

I have looked and looked at the code and tried modifications.

Can some one see the flaw?

Sorry meant to say "Has me baffled"

Hi, @cssystems

The action dbpAddRecord adds a new EMPTY record to a table (see help). To save the data into the record, you must use the action dbpSaveEdits at the end, but if you don't want it to "insert a blank record", just delete the action dbpAddRecord.

The action dbpSetAutoEdit (option: Yes) will save automatically the changes of the record while you are typing at any text entry linked to the database.

Regards.

dbpAddRecord "ARMDB" "Members"
SetVar "[ARMDB.Members.OSSTF]" "[FoundNumber]"
dbpSaveEdits "ARMDB" "Members"

Interesting that the dbpShowAll below creates the Blank record so if I leave out the dbpAddRecord it allows me to complete the fields of the record I am trying to add. Not sure why it works this way, but it works for me. As I said I have a similar program where the original routine works. That's why it is baffling.

If "[ARMDB.Members.$RecCount]" "=" "0"
    AlertBox "Ok" "No duplicates were found."
    dbpShowAll "ARMDB" "Members"
    dbpAddRecord "ARMDB" "Members"