By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,501 Members | 2,805 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,501 IT Pros & Developers. It's quick & easy.

New User Button

100+
P: 173
Alright peeps,

Im trying to add details to a database called "tab_main". I wana add details such as phone number, name, imei no, PUK code, tariff etc etc for a mobile phone user.

Ive created an empty form with all the neccesary text fields and also a seperate form for just the New User button (the way i would like it l ).

I need some help and advice................

How do i click on the New User Button and show the empty form on a new window? and also on the empty form, i need an 'add button' that will allow me to add the details once the form is completed??? ANY1 GOT THE full CODE FOR THIS? OR ARE THERE ANY EXAMPLES AVAILABLE FOR ME TO VIEW????????????

Ur response will be highly appreciated.... thank you
Nov 15 '06 #1
Share this Question
Share on Google+
4 Replies


MMcCarthy
Expert Mod 10K+
P: 14,534
Beany

I'm not sure what you mean. Normally to add records to a table or query you create a form bound to the table or query and put controls on the form bound to each of the fields. The form wizard can help with this.


Alright peeps,

Im trying to add details to a database called "tab_main". I wana add details such as phone number, name, imei no, PUK code, tariff etc etc for a mobile phone user.

Ive created an empty form with all the neccesary text fields and also a seperate form for just the New User button (the way i would like it l ).

I need some help and advice................

How do i click on the New User Button and show the empty form on a new window? and also on the empty form, i need an 'add button' that will allow me to add the details once the form is completed??? ANY1 GOT THE full CODE FOR THIS? OR ARE THERE ANY EXAMPLES AVAILABLE FOR ME TO VIEW????????????

Ur response will be highly appreciated.... thank you
Nov 17 '06 #2

NeoPa
Expert Mod 15k+
P: 31,494
I'm not sure exactly what you're after here, but I've designed a form class which enables the code to open one form from another. The calling object is automatically hidden until the called form is closed, at which time the calling form is reshown.

Class - classForm
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Private WithEvents frmTo As Form
  5.  
  6. Private frmParent As Form
  7.  
  8. Public Property Set frmFrom(frmValue As Form)
  9.     Set frmParent = frmValue
  10. End Property
  11.  
  12. Private Property Get frmFrom() As Form
  13.     Set frmFrom = frmParent
  14. End Property
  15.  
  16. Public Function ShowForm(strTo As String) As Boolean
  17.     ShowForm = True
  18.     'Handle error on OpenForm() only.
  19.     On Error GoTo ErrorSF
  20.     Call DoCmd.OpenForm(strTo)
  21.     On Error GoTo 0
  22.     Set frmTo = Forms(strTo)
  23.     frmFrom.Visible = False
  24.     Exit Function
  25.  
  26. ErrorSF:
  27.     ShowForm = False
  28.     Call ErrorHandler(strName:=strTo, _
  29.                       strFrom:=frmFrom.Name & ".ShowForm", _
  30.                       lngErrNo:=Err.Number, _
  31.                       strDesc:=Err.Description)
  32. End Function
  33.  
  34. '************************* Contained Object Method(s) *************************
  35. 'For these subroutines to be activated the contained object must have the
  36. ''On Close' property set to a valid subroutine within the contained object.
  37. Private Sub frmTo_Close()
  38.     frmFrom.Visible = True
  39.     Set frmTo = Nothing
  40. End Sub
  41. '******************************************************************************

This is an example of the code for (my main menu) form which uses it (as a calling and a called form).
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Private clsTo As New classForm
  5.  
  6. Private Sub Form_Open(Cancel As Integer)
  7.     Call DoCmd.Restore
  8.     Set clsTo.frmFrom = Me
  9. End Sub
  10.  
  11. Private Sub cmdAdHocMenu_Click()
  12.     Call clsTo.ShowForm(strTo:="frmAdHocMenu")
  13. End Sub
  14.  
  15. Private Sub cmdCustSPMenu_Click()
  16.     Call clsTo.ShowForm(strTo:="frmCustSPMenu")
  17. End Sub
  18.  
  19. Private Sub cmdExit_Click()
  20.     Call DoCmd.Close(ObjectType:=acForm, ObjectName:=Name)
  21. End Sub
  22.  
  23. Private Sub Form_Close()
  24.     'Allows container to handle event.
  25. End Sub
Notice the Form_Close() sub MUST exist - even if it contains only a comment line.
Nov 18 '06 #3

PEB
Expert 100+
P: 1,418
PEB
It seems me that this is a wizard for this!

Main/Subform wizard that creates separate forms and fills them on clicking a bouton... But in the old versions this wizard isn't present!

The code that you have to adapt is:

Expand|Select|Wrap|Line Numbers
  1. Sub Form_Current()
  2. On Error GoTo Form_Current_Err
  3.  
  4.     If ChildFormIsOpen() Then FilterChildForm
  5.  
  6. Form_Current_Exit:
  7.     Exit Sub
  8.  
  9. Form_Current_Err:
  10.     MsgBox Error$
  11.     Resume Form_Current_Exit
  12.  
  13. End Sub
  14. Sub ToggleLink_Click()
  15. On Error GoTo ToggleLink_Click_Err
  16. default_object_value = Me.[ID_obj]
  17.     If ChildFormIsOpen() Then
  18.         CloseChildForm
  19.     Else
  20.         OpenChildForm
  21.         FilterChildForm
  22.     End If
  23.  
  24. ToggleLink_Click_Exit:
  25.     Exit Sub
  26.  
  27. ToggleLink_Click_Err:
  28.     MsgBox Error$
  29.     Resume ToggleLink_Click_Exit
  30.  
  31. End Sub
  32. Private Sub FilterChildForm()
  33.  
  34.     If Me.NewRecord Then
  35.         Forms![Object_info].DataEntry = True
  36.     Else
  37.         Forms![Object_info].Filter = "[ID_obj] = " & Me.[ID_obj]
  38.         Forms![Object_info].FilterOn = True
  39.     End If
  40.  
  41. End Sub
  42. Private Sub OpenChildForm()
  43.  
  44.     DoCmd.OpenForm "Object_info", acFormDS
  45.     If Not Me.[ToggleLink] Then Me![ToggleLink] = True
  46.  
  47. End Sub
  48. Private Sub CloseChildForm()
  49.  
  50.     DoCmd.Close acForm, "Object_info"
  51.     If Me![ToggleLink] Then Me![ToggleLink] = False
  52.  
  53. End Sub
  54. Private Function ChildFormIsOpen()
  55.  
  56.     ChildFormIsOpen = (SysCmd(acSysCmdGetObjectState, acForm, "Object_info") And acObjStateOpen) <> False
  57.  
  58. End Function
  59.  
  60.  
  61.  
Alright peeps,

Im trying to add details to a database called "tab_main". I wana add details such as phone number, name, imei no, PUK code, tariff etc etc for a mobile phone user.

Ive created an empty form with all the neccesary text fields and also a seperate form for just the New User button (the way i would like it l ).

I need some help and advice................

How do i click on the New User Button and show the empty form on a new window? and also on the empty form, i need an 'add button' that will allow me to add the details once the form is completed??? ANY1 GOT THE full CODE FOR THIS? OR ARE THERE ANY EXAMPLES AVAILABLE FOR ME TO VIEW????????????

Ur response will be highly appreciated.... thank you
Nov 18 '06 #4

100+
P: 173
thanks fellas,

im gonna have a try with the info u have provided!

cheers
Nov 18 '06 #5

Post your reply

Sign in to post your reply or Sign up for a free account.