473,795 Members | 2,922 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

First Function - One Problem!

I've gotten my first function to work - to build a sql string to load a
list box. I call the function whenever I want the list box loaded

1. When a customer is chosen - opens the frmCust and shows the
lstItems with all the customer's items (works great)

2. When an item is deleted - goes back to the frmCust and shows the
lstItems and the deleted item is gone (works fine)

3. When an item is changed - goes back to the frmCust and show the
changed info (if it is one of the listbox fields) - Works

4. When an item is added - goes back to the frmCust and should show
the new item in the list (NOT WORKING)

Change uses the exact same code as add. Delete uses a "delete item"
button.

I step through the code and look at the tblCustomerItem s at each step,
and see that the item is NOT in the table until after the function has
excecuted. I tried "DoCmd.RunComma nd acCmdsave" and that didn't work.

Gotta be something easy - I'm missing. Thanks! Sara

Code:

Private Sub cmdCloseGarment _Click()
On Error GoTo Err_cmdCloseGar ment_Click

Dim CustID As Long
CustID = Me.txtCustID
Dim intfcnReturn As Integer

' User enters (or updates) the item and presses CLOSE when done

' Tell the form NOT to cancel after the call to the Update event
' Forcing the Before Update to make sure if there is damage or soil,
there is
' detail on the problem entered

' Run the Before_Update event
' If the user is missing details, this sub will set StopMe to send the
user back to the
' form to insert details (required if damage or soiled item)

Form_BeforeUpda te (False)

' Determine if the user should be stopped - if the user checked damage
or soil, but
' didn't input details
If StopMe = True Then
Forms!frmCust.l stItems = CustID
Forms!frmCust!l stItems.Requery
Else

' Try to force the record save
' DoCmd.RunComman d acCmdSave

' Update has been captured on the table and the audit; go back to the
cust form with
' items added/update

' Set the value for the function

' Call the Function to repopulate the list of items for the customer
' get the return value from the function
If fcnFillGarmentL ist(Me.txtCustI D) = False Then
MsgBox "Function Fill Garment List Failed. Call Sara", ,
"Function Fail"
Exit Sub
End If

' MsgBox fcnFillGarmentL ist(Me.txtCustI D)

' Close the garment form and return to the customer form, with updated
list
DoCmd.Close acForm, Me.Name
End If
' Reason: Want to requery the items list, not customers if updating
item only

Exit_cmdCloseGa rment_Click:
Exit Sub

Err_cmdCloseGar ment_Click:
MsgBox Err.Number & " " & Err.Description
Resume Exit_cmdCloseGa rment_Click
End Sub

Nov 13 '05 #1
4 2057
Hi Sara

Not clear whether you are using a list box to show your garments or a
subform. The DB I sent you worked with a subform in which case it is easy to
add, edit or delete garments. No code needed.
What are you trying to achieve? Damaged or soiled should just be a checkbox
on the subform and held in the JnCustomerGarme nt table

Phil
"sara" <sa*******@yaho o.com> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.com.. .
I've gotten my first function to work - to build a sql string to load a
list box. I call the function whenever I want the list box loaded

1. When a customer is chosen - opens the frmCust and shows the
lstItems with all the customer's items (works great)

2. When an item is deleted - goes back to the frmCust and shows the
lstItems and the deleted item is gone (works fine)

3. When an item is changed - goes back to the frmCust and show the
changed info (if it is one of the listbox fields) - Works

4. When an item is added - goes back to the frmCust and should show
the new item in the list (NOT WORKING)

Change uses the exact same code as add. Delete uses a "delete item"
button.

I step through the code and look at the tblCustomerItem s at each step,
and see that the item is NOT in the table until after the function has
excecuted. I tried "DoCmd.RunComma nd acCmdsave" and that didn't work.

Gotta be something easy - I'm missing. Thanks! Sara

Code:

Private Sub cmdCloseGarment _Click()
On Error GoTo Err_cmdCloseGar ment_Click

Dim CustID As Long
CustID = Me.txtCustID
Dim intfcnReturn As Integer

' User enters (or updates) the item and presses CLOSE when done

' Tell the form NOT to cancel after the call to the Update event
' Forcing the Before Update to make sure if there is damage or soil,
there is
' detail on the problem entered

' Run the Before_Update event
' If the user is missing details, this sub will set StopMe to send the
user back to the
' form to insert details (required if damage or soiled item)

Form_BeforeUpda te (False)

' Determine if the user should be stopped - if the user checked damage
or soil, but
' didn't input details
If StopMe = True Then
Forms!frmCust.l stItems = CustID
Forms!frmCust!l stItems.Requery
Else

' Try to force the record save
' DoCmd.RunComman d acCmdSave

' Update has been captured on the table and the audit; go back to the
cust form with
' items added/update

' Set the value for the function

' Call the Function to repopulate the list of items for the customer
' get the return value from the function
If fcnFillGarmentL ist(Me.txtCustI D) = False Then
MsgBox "Function Fill Garment List Failed. Call Sara", ,
"Function Fail"
Exit Sub
End If

' MsgBox fcnFillGarmentL ist(Me.txtCustI D)

' Close the garment form and return to the customer form, with updated
list
DoCmd.Close acForm, Me.Name
End If
' Reason: Want to requery the items list, not customers if updating
item only

Exit_cmdCloseGa rment_Click:
Exit Sub

Err_cmdCloseGar ment_Click:
MsgBox Err.Number & " " & Err.Description
Resume Exit_cmdCloseGa rment_Click
End Sub

Nov 13 '05 #2
I did use the database you sent for learning, but this is a list box
(when I do "orders" I am doing a subform).

I need to capture all edits as the user is so new and nervous. In this
case, I am trying to show the garment that was just added or changed in
the list box when the user finishes the ad or update (or NOT show it in
the case of "delete" where I'm just changing the status to "I"
(inactive). For all that, I need code, hence the function and I used
Allen Browne's audit Trail code (which works great, by the way).

Damage and Soil is not a problem; it's getting the new record to show
in the list box that isn't happening. Changes show; deleted items
disappear.

Does this help explain the problem?

Sara

Nov 13 '05 #3
Not really.

Do you have a microphone and headset and messenger, in which case we can
talk the problem through

Phil
"sara" <sa*******@yaho o.com> wrote in message
news:11******** *************@g 49g2000cwa.goog legroups.com...
I did use the database you sent for learning, but this is a list box
(when I do "orders" I am doing a subform).

I need to capture all edits as the user is so new and nervous. In this
case, I am trying to show the garment that was just added or changed in
the list box when the user finishes the ad or update (or NOT show it in
the case of "delete" where I'm just changing the status to "I"
(inactive). For all that, I need code, hence the function and I used
Allen Browne's audit Trail code (which works great, by the way).

Damage and Soil is not a problem; it's getting the new record to show
in the list box that isn't happening. Changes show; deleted items
disappear.

Does this help explain the problem?

Sara

Nov 13 '05 #4
You are amazing! I actually put in acCmdSaveRecord and it worked. I
looked through tons of stuff on save and apparently the acCmdSave was
saving the FORM, and I needed to save the record. I fixed that, and
have a new problem.

Should I explain it here or do a new post? (It relates to running a
function to validate an email address, and wanting to put the cursor
back in the email address field if the update fails).
BTW: I think my PC has a microphone, but I don't have a headset and I
don't know what a messenger is. The IT guy at work isn't in today, but
I could ask him - for future (I am certain I will have more
problems/questions before this is done! This db is supposed to help me
learn how to develop a simple app, really Understand what I'm doing,
and have a model for apps I can build at work).

Sara

Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
9893
by: Peter Rothenbuecher | last post by:
Hello, when I try to compile the following code with g++ -o client client.c #include<sys/socket.h> #include<stdio.h> #include<stdlib.h> #define ADDRESS "mysocket"; #define MAXLEN 200;
5
5438
by: cj | last post by:
Thanks to everyone that has helped me. Now I'm trying to write my first program. I have an example of one that I need to write about. Any help getting me started is appreciated. I'm having trouble getting my compiler to work, access to my a drive is denied, anyone know why this is? Ok here is the info for my program: The two laws of electricity are used in this program. Law #1 The first is Ohm's Law which relates voltage, curret, and...
16
4830
by: Martin Joergensen | last post by:
Hi, I wanted to try something which I think is a very good exercise... I read in data from the keyboard and store them in a structure. There's a pointer called "data_pointer" which I use to keep track on the structures... But it's a bit confusing - my program won't compile and I don't know what to do about the warnings/error messages. c:\documents and settings\dell\Desktop\test\main.c(5) : warning
1
2199
by: huzheng001 | last post by:
I have develop a on-line dictionary website, http://www.stardict.org I meet a problem: Here is two lines of js codes: document.getElementById("wordlist").innerHTML = ""; document.getElementById("definition").innerHTML = "line1<br>line2"; The corresponding html codes are: <table width="100%"> <tr> <td width="25%" valign="top"><div id="wordlist" width="100%" style=' overflow-y:auto; height:352px;'></div></td>
7
32392
by: michigaki | last post by:
hello, we are having problems in compiling a 'slightly' altered x264. We are always receiving a 'helloWorld' undeclared (first use this function) error. We may be commiting a very simple error but we just have to ask after looking through possible solutions that have not worked. So far, we are able to successfully compile the x263 source (an unaltered one from the VideoLAN downloads section) using the instructions found at...
15
9049
by: robert maas, see http://tinyurl.com/uh3t | last post by:
Here's the source: #include <stdio.h> #include <errno.h> main () { char* str = "9999999999"; long long int llin; char* endptr; /* Set by strtoll */ int nch; errno = 0; llin = strtoll(str, &endptr, 10); printf("errno=%d\n", errno);
10
2679
by: Tom Cole | last post by:
While I've done javascript work for as long as I can remember (since Netscape first released it), I've only ever used it for trivial things, change a color here, validate a text element there, blah blah blah. With Ajax (actually, the uncovering of the XmlHTTPRequest object) I absolutely see the benefit of moving more of the UI work to the client, rather than doing page refreshes. I know there are a bunch of libraries out there...
0
1566
Frinavale
by: Frinavale | last post by:
I have a peculiar problem... Background: I have a function that I don't want the user to execute more than once while they are waiting for it to process; therefore, I disable all of the controls on the page via some JavaScript before the request is sent. This function takes some time to execute because it has to communicate with hardware that is rather slow. This slowness combined with a little bit of lag sometimes results in a ...
1
2775
by: JohnCox | last post by:
I have a simple Win32 DLL I wrote named "SimpleLib" that exports two functions. It is written in C++ and compiled with __stdcall (/Gz) and with the preprocessor definition _MBCS (not Unicode). The first function is called "StrFirst" and takes in a LPTSTR as the first parameter and a long as the second, like this: SIMPLELIB_API int StrFirst(LPTSTR str, long num); The second function is essentially the same thing, but with the order of the...
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10439
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9043
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7541
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6783
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3727
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.