Add form

Beany

Registered User.
Local time
Today, 13:11
Joined
Nov 12, 2006
Messages
155
Hi,

ive attached my database to this post.....

on it i have form called newaddform which is connected to table tab_data..

Im having problems with this form.............

so (please) can someone modify this form for me, so it will allow me to add stuff to the table tab_data....

i want the form to be empty when you go into it.......

ur help will be appreciated

thanks
 

Attachments

on it i have form called newaddform which is connected to table tab_data..

Check the attached Dbase. I changed it to ensure that the form is actually bound to the tab_data.

i want the form to be empty when you go into it.......

I changed the form proprty to Data entry = Yes. This will allow you to enter new data when the form opens.


Hth
 

Attachments

thanks rak,

i noticed a slight problem,

if i complete the form and then erase all the information it adds a blank record in my table!! why?

is there a way i can avoid this???
 
if i complete the form and then erase all the information it adds a blank record in my table!! why?

You shouldn't enter data and erase the data entered. Upon entry of any data in one field a new record is made. If you erase the data, you should delete that (new) record. But as said, why enter data and not enter data after all ?
 
So Beany, if you want to erase an entry - put a button on your form to do so and put:
Code:
Me.Undo
to undo the entry and set the form back to empty.
 
for the clear button im using the following code:

Code:
Private Sub Command25_Click()
Dim intResponse As Integer

intResponse = MsgBox("Are you sure you want to clear all entries?", vbYesNo, "Remove")

If intResponse = 6 Then
Me.Undo

   Me.site.Value = " "
   Me.address_1.Value = " "
   Me.address_2.Value = " "
   Me.address_3.Value = " "
   Me.postcode.Value = " "
   Me.ip.Value = " "
   Me.username.Value = " "
   Me.password.Value = " "
   Me.use.Value = " "
   Me.tel.Value = " "
   Me.line_provider.Value = " "
   Me.line_status.Value = " "
   Me.product.Value = " "
   Me.provider.Value = " "
   Me.type.Value = " "
   Me.notes.Value = " "
    Else
End If


End Sub

me.undo doesnt work.... is there sumat with my code???
 
It worked for me, but try this one instead:
Code:
    DoCmd.RunCommand acCmdSelectRecord
    DoCmd.RunCommand acCmdUndo
 
would that code go in the same place as me.undo???

or elsewhere?
 
Hi Bob,

ive tried inserting your code but unfortunately it brings up two delete messages, 1) from my code, 2) from the two lines of code you provided.......

if you look at my code for the clear button, it brings up a message asking you to confirm if you want to delete...... then i get a message straight after suggesting that 1 record will be deleted....(from the table i think)

but at the end of this i still get an empty record in my table!

the code i used:

Code:
Private Sub Command25_Click()
Dim intResponse As Integer

intResponse = MsgBox("Are you sure you want to clear all entries?", vbYesNo, "Remove")

If intResponse = 6 Then
DoCmd.RunCommand acCmdSelectRecord
    DoCmd.RunCommand acCmdUndo

   Me.site.Value = " "
   Me.address_1.Value = " "
   Me.address_2.Value = " "
   Me.address_3.Value = " "
   Me.postcode.Value = " "
   Me.ip.Value = " "
   Me.username.Value = " "
   Me.password.Value = " "
   Me.use.Value = " "
   Me.tel.Value = " "
   Me.line_provider.Value = " "
   Me.line_status.Value = " "
   Me.product.Value = " "
   Me.provider.Value = " "
   Me.type.Value = " "
   Me.notes.Value = " "
    Else
End If


End Sub


there must be sumat wrong with my code???
 
You are undo-ing all the changes, then why put blanks everywhere?? The changes (add I presume) have allready been undone but you add the blank record...
 
The Mailman,

ive treid it that way but it gives errors...

can you please help me create some code??

thanks
 
You problem is you are creating a record with blank values after you undo your action. Take out all of the below code from you procedure and it should work

Me.site.Value = " "
Me.address_1.Value = " "
Me.address_2.Value = " "
Me.address_3.Value = " "
Me.postcode.Value = " "
Me.ip.Value = " "
Me.username.Value = " "
Me.password.Value = " "
Me.use.Value = " "
Me.tel.Value = " "
Me.line_provider.Value = " "
Me.line_status.Value = " "
Me.product.Value = " "
Me.provider.Value = " "
Me.type.Value = " "
Me.notes.Value = " "
Else
 
im using now:

Code:
Private Sub Command25_Click()
Dim intResponse As Integer

intResponse = MsgBox("Are you sure you want to clear all entries?", vbYesNo, "Remove")

If intResponse = 6 Then
    DoCmd.RunCommand acCmdSelectRecord
    DoCmd.RunCommand acCmdUndo

End If


End Sub

but it brings up two delete messages and creates an empty record in my table??

im pulling my hair with this!
 
I think (have not tested it right now)

Me.Undo

Should do the trick... ???
 
Mailman ur a star........

thanks buddy!!!!

it works.....
 

Users who are viewing this thread

Back
Top Bottom