Adding rows using check box / button

suzacaru7

New member
Local time
Today, 14:20
Joined
Aug 4, 2008
Messages
6
Hi,

I have a database which I store clients information. One of the tables consists of information regarding treatments the clients take from my salon. Every therapy (coarse) a client take, consist of 15 sessions treatments. The client can buy for the coarse by full or for very session when she comes at the salon.

I wish to make a kind of button or check box, that when it is ticked or clicked, two free rows will be inserted automatically. I need to use this function, because if my client pays for 15 treatements at one go, the client will get 2 free sessions (treatements) and so I will add 2 more rows.

Can you please tell me how to do this?

Thanks

Sue
 
in order for rows to "stick" in your table, there has to be at least one field of data inserted in the new record. you cannot have new records that are simply blank across every field. If you have defaults that are set, open the recordset, and addnew records that way:
Code:
dim rs as recordset

set rs=currentdb.openrecordset("tablename", dbopendynaset)
  with rs
    .addnew
    .addnew
  end with
rs.close
 
HI, thanks for your information. I understood your concept, but what did you mean exectly when you said:

"If you have defaults that are set, open the recordset, and addnew records that way:"

What defaults are they? What are recordset? And where do I have to add that code?

Thanks

sue
 
i apologize sue. I guess you don't need defaults to add rows. i'm sorry about that. The attachment will help you understand the concept...:)
 

Attachments

I copied the code you gave me, and i got an error!!
____________________________________________________________________
Private Sub Command19_Click()
Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("Slimming_T", dbOpenDynaset)
With rs
.AddNew
.Update
.AddNew
.Update
End With
MsgBox "Client paid full. 2 Free Sessions " & rs.Name & "!"
rs.Close
Set rs = Nothing
End Sub
______________________________________________________________________

I changed the words in purple. When I debug the code, the error is in the line with the red colour. Do I have to change that property also? Or do I have to change something else?

Thanks a lot

sue
 
try it without using the name property. just issue a string message without a concatenated string. if that doesn't work, try DAO.recordset instead of just RECORDSET. It would also help to know the error message. That will tell you if there is another complication elsewhere.
 

Users who are viewing this thread

Back
Top Bottom