Connecting Tech Pros Worldwide Forums | Help | Site Map

can't see new customer in control

Member
 
Join Date: Nov 2006
Posts: 59
#1: Feb 18 '08
I have in form frmworkshop one command button newcustomer.
When I click him then open frmcustomer and I can write new customer.
After closed frmcustomer I can't see new customer in control customer on form frmworkshop.
I must close and open frmworkshop if i want see new customer in control.
How can I solve this problem.

Delerna's Avatar
Expert
 
Join Date: Jan 2008
Location: Sydney
Posts: 790
#2: Feb 18 '08

re: can't see new customer in control


you will need a public function on frmworkshop that you can call from frmcustomer when it closes.

The code in the public function will simply be
Expand|Select|Wrap|Line Numbers
  1. Me.Refresh
  2.  
that code will cause the form to refresh and display the new data.
I am taking it for granted that you know something about VBA here.
Member
 
Join Date: Nov 2006
Posts: 59
#3: Feb 18 '08

re: can't see new customer in control


Quote:

Originally Posted by Delerna

you will need a public function on frmworkshop that you can call from frmcustomer when it closes.

The code in the public function will simply be

Expand|Select|Wrap|Line Numbers
  1. Me.Refresh
  2.  
that code will cause the form to refresh and display the new data.
I am taking it for granted that you know something about VBA here.

Would you like explain me how can I write public function and where I must put her in form,please.
Delerna's Avatar
Expert
 
Join Date: Jan 2008
Location: Sydney
Posts: 790
#4: Feb 18 '08

re: can't see new customer in control


OK
To get to the code page of the form click the form you want and in the toolbar at the top, click the icon that has a square with a red a green and a yellow dots on it. If you hover over the icon it will say "Code" in the tooltip.

In the code page for form frmworkshop
scroll right to the end and paste this code there

Expand|Select|Wrap|Line Numbers
  1. Public Sub RefreshTheForm()
  2.    Me.Refresh
  3.    'You may need more code in here to perform other tasks
  4. End Sub
  5.  
you can actually paste the code anywhere on the code page but you must make sure you don't paste it inside another sub.

Now on the code page for the frmcustomer
scroll right to the end and paste this code there

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Unload(Cancel As Integer)
  2.    Forms.frmworkshop.RefreshTheForm()
  3. End Sub
  4.  
Now when frmcustomer unloads (ie closes) it will execute the code in the second code block above. The code there calls the sub in the first code block which refreshes your form

Not trying to be rude but may I suggest, that if you want to create really good databases, open up the access help documents goto the contents tab and have a look at the visual basic conceptual topics. Try them out and experiment.
We are always here to help you over any sticky patches, but you need to get some of the basics down for you self and the help files are pretty good for that.
Member
 
Join Date: Nov 2006
Posts: 59
#5: Feb 18 '08

re: can't see new customer in control


Quote:

Originally Posted by Delerna

OK
To get to the code page of the form click the form you want and in the toolbar at the top, click the icon that has a square with a red a green and a yellow dots on it. If you hover over the icon it will say "Code" in the tooltip.

In the code page for form frmworkshop
scroll right to the end and paste this code there

Expand|Select|Wrap|Line Numbers
  1. Public Sub RefreshTheForm()
  2.    Me.Refresh
  3.    'You may need more code in here to perform other tasks
  4. End Sub
  5.  
you can actually paste the code anywhere on the code page but you must make sure you don't paste it inside another sub.

Now on the code page for the frmcustomer
scroll right to the end and paste this code there

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Unload(Cancel As Integer)
  2.    Forms.frmworkshop.RefreshTheForm()
  3. End Sub
  4.  
Now when frmcustomer unloads (ie closes) it will execute the code in the second code block above. The code there calls the sub in the first code block which refreshes your form

Not trying to be rude but may I suggest, that if you want to create really good databases, open up the access help documents goto the contents tab and have a look at the visual basic conceptual topics. Try them out and experiment.
We are always here to help you over any sticky patches, but you need to get some of the basics down for you self and the help files are pretty good for that.

when I put you code in frmcustomer return me same error.
After write Forms. I can put only application, count,Item or parent.
If I write Forms.frmworkshop.refreshTheForm() return me error Expected:=
Delerna's Avatar
Expert
 
Join Date: Jan 2008
Location: Sydney
Posts: 790
#6: Feb 19 '08

re: can't see new customer in control


OOPS getting too used to writing java script

in VBA and VB and VBScript
Expand|Select|Wrap|Line Numbers
  1. Forms.frmworkshop.RefreshTheForm()
  2.  
is the way to call a function and functions always return a value

In your case you don't want to return a value, you just want to execute a subroutine, so change it to the following.

Expand|Select|Wrap|Line Numbers
  1. Forms!frmworkshop.RefreshTheForm
  2.  
Note the absence of the brackets. Also the . changed to !
The . works but the ! is correct.
Welcome to the wonderful world of debugging, the act of fixing the silly things that programmers write while not thinking.
Reply